diff --git a/lib/mercenary/presenter.rb b/lib/mercenary/presenter.rb index 0521ee0..c9edb47 100644 --- a/lib/mercenary/presenter.rb +++ b/lib/mercenary/presenter.rb @@ -23,7 +23,7 @@ def usage_presentation # Returns the string representation of the options def options_presentation return nil unless command_options_presentation || parent_command_options_presentation - [command_options_presentation, parent_command_options_presentation].compact.join("\n") + [command_options_presentation, parent_command_options_presentation].join("\n\n").rstrip end def command_options_presentation @@ -37,7 +37,7 @@ def command_options_presentation # Returns the string representation of the options for parent commands def parent_command_options_presentation return nil unless command.parent - Presenter.new(command.parent).options_presentation + Presenter.new(command.parent).command_options_presentation end # Public: Builds a string representation of the subcommands @@ -52,7 +52,7 @@ def subcommands_presentation # # Returns the command header as a String def command_header - header = "#{command.identity}" + header = "\n#{command.identity}" header << " -- #{command.description}" if command.description header end diff --git a/spec/presenter_spec.rb b/spec/presenter_spec.rb index f61ed45..9b82eed 100644 --- a/spec/presenter_spec.rb +++ b/spec/presenter_spec.rb @@ -15,7 +15,7 @@ end it "knows how to present the command" do - expect(presenter.command_presentation).to eql("script_name subcommand 1.4.2 -- Do all the things.\n\nUsage:\n\n script_name subcommand\n\nOptions:\n -1, --one The first option\n -2, --two The second option") + expect(presenter.command_presentation).to eql("\nscript_name subcommand 1.4.2 -- Do all the things.\n\nUsage:\n\n script_name subcommand\n\nOptions:\n -1, --one The first option\n -2, --two The second option") end it "knows how to present the subcommands, without duplicates for aliases" do