Skip to content

Commit

Permalink
Ensure that supercommand flags are not duplicated in output
Browse files Browse the repository at this point in the history
  • Loading branch information
mdippery committed Dec 13, 2018
1 parent 3b4647b commit 7822632
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions spec/presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@
let(:presenter) { described_class.new(command) }

before(:each) do
supercommand.option "version", "-v", "--version", "Show version"
supercommand.option "help", "-h", "--help", "Help!"

command.version "1.4.2"
command.description "Do all the things."
command.option "help", "-h", "--help", "Help!"
command.option "one", "-1", "--one", "The first option"
command.option "two", "-2", "--two", "The second option"
command.alias :cmd
supercommand.commands[command.name] = command
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("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\n -v, --version Show version\n -h, --help Help!")
end

it "knows how to present the subcommands, without duplicates for aliases" do
Expand All @@ -29,7 +33,7 @@
end

it "knows how to present the options" do
expect(presenter.options_presentation).to eql(" -1, --one The first option\n -2, --two The second option")
expect(presenter.options_presentation).to eql(" -1, --one The first option\n -2, --two The second option\n -v, --version Show version\n -h, --help Help!")
end

it "allows you to say print_* instead of *_presentation" do
Expand Down

0 comments on commit 7822632

Please sign in to comment.