Skip to content

Commit 314ec2c

Browse files
committed
Merge pull request #42 from jekyll/print-options-from-parent
Merge pull request 42
2 parents 70c7c88 + cd5941f commit 314ec2c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/mercenary/presenter.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,24 @@ def usage_presentation
2222
#
2323
# Returns the string representation of the options
2424
def options_presentation
25+
return nil unless command_options_presentation || parent_command_options_presentation
26+
[command_options_presentation, parent_command_options_presentation].compact.join("\n")
27+
end
28+
29+
def command_options_presentation
2530
return nil unless command.options.size > 0
2631
command.options.map(&:to_s).join("\n")
2732
end
2833

34+
# Public: Builds a string representation of the options for parent
35+
# commands
36+
#
37+
# Returns the string representation of the options for parent commands
38+
def parent_command_options_presentation
39+
return nil unless command.parent
40+
Presenter.new(command.parent).options_presentation
41+
end
42+
2943
# Public: Builds a string representation of the subcommands
3044
#
3145
# Returns the string representation of the subcommands

0 commit comments

Comments
 (0)