Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce visual separation to improve readability #48

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/mercenary/presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down