File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed
spec/support/shared_examples Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -37,9 +37,19 @@ def self.command_name(name)
3737 # @since 0.1.0
3838 # @api private
3939 def self . command_name_and_arguments ( command , name )
40- usage = "\n Usage:\n #{ name } #{ arguments ( command ) } "
40+ usage = "\n Usage:\n "
4141
42- return usage + " | #{ name } SUBCOMMAND" if command . subcommands . any?
42+ callable_root_command = false
43+ if command . new . respond_to? ( :call )
44+ callable_root_command = true
45+ usage += " #{ name } #{ arguments ( command ) } "
46+ end
47+
48+ if command . subcommands . any?
49+ usage += " "
50+ usage += "|" if callable_root_command
51+ usage += " #{ name } SUBCOMMAND"
52+ end
4353
4454 usage
4555 end
Original file line number Diff line number Diff line change 2727 expect ( error ) . to eq ( expected )
2828 end
2929
30+ it "shows root command help considering if it implements #call" do
31+ output = capture_output { cli . call ( arguments : %w[ namespace --help ] ) }
32+ expected = <<~DESC
33+ Command:
34+ #{ cmd } namespace
35+
36+ Usage:
37+ #{ cmd } namespace SUBCOMMAND
38+
39+ Description:
40+ This is a namespace
41+
42+ Subcommands:
43+ sub-command # I'm a concrete command
44+
45+ Options:
46+ --help, -h # Print this help
47+ DESC
48+ expect ( output ) . to eq ( expected )
49+ end
50+
3051 it "shows run's help" do
3152 output = capture_output { cli . call ( arguments : %w[ i run --help ] ) }
3253 expected = <<~DESC
You can’t perform that action at this time.
0 commit comments