Skip to content

Commit

Permalink
Remove Command#root? method
Browse files Browse the repository at this point in the history
It is more direct to just check the truthiness of Command#parent
instead.
  • Loading branch information
mdippery committed Dec 11, 2018
1 parent 6e6f85a commit 3b4647b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 11 deletions.
5 changes: 0 additions & 5 deletions lib/mercenary/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ def initialize(name, parent = nil)
@aliases = []
end

# Public: Returns true if this command has no parent
def root?
parent.nil?
end

# Public: Sets or gets the command version
#
# version - the command version (optional)
Expand Down
3 changes: 2 additions & 1 deletion lib/mercenary/presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ def options_presentation

def command_options_presentation
return nil if command.options.empty?

options = command.options
options -= command.parent.options unless command.root?
options -= command.parent.options if command.parent
options.map(&:to_s).join("\n")
end

Expand Down
5 changes: 0 additions & 5 deletions spec/command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@
expect(add_sub.call(command).parent).to eq(command)
end

it "can tell whether it is a parent command or not" do
expect(command.root?).to be true
expect(command_with_parent.root?).to be false
end

it "can set its version" do
version = "1.4.2"
command.version version
Expand Down

0 comments on commit 3b4647b

Please sign in to comment.