Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/kamal/cli/main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,17 @@ def config
end
end

desc "alias", "Show available aliases"
def alias
if KAMAL.config.aliases.any?
KAMAL.config.aliases.each do |name, alias_config|
puts "#{name.ljust(30)} #{alias_config.command}"
Copy link

Copilot AI Sep 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The magic number 30 for column width is hardcoded. Consider extracting this to a constant like ALIAS_NAME_COLUMN_WIDTH = 30 to improve maintainability and make the formatting intention clearer.

Copilot uses AI. Check for mistakes.
end
else
say "No aliases configured"
end
end

desc "docs [SECTION]", "Show Kamal configuration documentation"
def docs(section = nil)
case section
Expand Down
32 changes: 32 additions & 0 deletions test/cli/alias_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require_relative "cli_test_case"

class CliAliasTest < CliTestCase
test "alias with aliases" do
run_command("alias", config_file: "deploy_with_aliases").tap do |output|
assert_match(/info\s+details/, output)
assert_match(/console\s+app exec --reuse -p -r console "bin\/console"/, output)
assert_match(/exec\s+app exec --reuse -p -r console/, output)
assert_match(/rails\s+app exec --reuse -p -r console rails/, output)
assert_match(/primary_details\s+details -p/, output)
end
end

test "alias without aliases" do
run_command("alias", config_file: "deploy_simple").tap do |output|
assert_match(/No aliases configured/, output)
end
end

test "alias with destination" do
run_command("alias", "-d", "elsewhere", config_file: "deploy").tap do |output|
assert_match(/other_config\s+config -c config\/deploy2.yml/, output)
end
end

private
def run_command(*command, config_file: "deploy_simple")
with_argv([ *command, "-c", "test/fixtures/#{config_file}.yml" ]) do
stdouted { Kamal::Cli::Main.start }
end
end
end