Skip to content

Commit

Permalink
Merge pull request #12 from DanielGilchrist/fix-subcommand-summary
Browse files Browse the repository at this point in the history
Fix: --help summary for subcommands shows parents summary
  • Loading branch information
devnote-dev authored Sep 17, 2023
2 parents c897596 + a8b075a commit e606b72
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions spec/formatter_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,18 @@ private class GreetCommand < Cling::MainCommand
end
end

class WelcomeCommand < Cling::Command
def setup : Nil
@name = "welcome"
@summary = @description = "sends a friendly welcome message"
end

def run(arguments : Cling::Arguments, options : Cling::Options) : Nil
end
end

command = GreetCommand.new
command.add_command WelcomeCommand.new
formatter = Cling::Formatter.new

describe Cling::Formatter do
Expand All @@ -26,6 +37,9 @@ describe Cling::Formatter do
Usage:
\tgreet <arguments> [options]
Commands:
\twelcome sends a friendly welcome message
Arguments:
\tname the name of the person (required)
Expand All @@ -45,6 +59,9 @@ describe Cling::Formatter do
Usage:
\tgreet <arguments> [options]
Commands:
\twelcome sends a friendly welcome message
Arguments:
\tname the name of the person (required)
Expand Down
2 changes: 1 addition & 1 deletion src/cling/formatter.cr
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ module Cling
io << "Commands:"
commands.each do |cmd|
io << "\n\t"
if summary = command.summary
if summary = cmd.summary
cmd.name.ljust(io, max_space, ' ')
io << summary
else
Expand Down

0 comments on commit e606b72

Please sign in to comment.