File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -1248,8 +1248,8 @@ defmodule Arca.Cli do
12481248 _ -> true
12491249 end
12501250
1251- # Format the command list
1252- command_list =
1251+ # Get command names and descriptions
1252+ commands_with_descriptions =
12531253 visible_commands
12541254 |> Enum . map ( fn module ->
12551255 { cmd_atom , opts } = apply ( module , :config , [ ] ) |> List . first ( )
@@ -1259,8 +1259,21 @@ defmodule Arca.Cli do
12591259 end )
12601260 # Sort by name (alphabetically) if sorting is enabled
12611261 |> maybe_sort_commands ( should_sort )
1262+
1263+ # Calculate the maximum command name length to ensure proper alignment
1264+ max_name_length =
1265+ commands_with_descriptions
1266+ |> Enum . map ( fn { name , _ } -> String . length ( name ) end )
1267+ |> Enum . max ( fn -> 0 end )
1268+
1269+ # Add 2 spaces of padding after the longest command name
1270+ padding_width = max_name_length + 2
1271+
1272+ # Format the command list with dynamic padding
1273+ command_list =
1274+ commands_with_descriptions
12621275 |> Enum . map ( fn { name , about } ->
1263- padding = String . duplicate ( " " , max ( 0 , 20 - String . length ( name ) ) )
1276+ padding = String . duplicate ( " " , max ( 0 , padding_width - String . length ( name ) ) )
12641277 " #{ name } #{ padding } #{ about } "
12651278 end )
12661279
You can’t perform that action at this time.
0 commit comments