Commit b5dc7c66 authored by Marin Usalj's avatar Marin Usalj

refactored a bit, made it more explicit

parent a725d61a
module Pod
class Command
class Help < Command
self.summary = 'Show help for the given command'
self.summary = 'Show help for the given command.'
self.arguments = '[COMMAND]'
def self.parse(argv)
command_needs_help = [argv.shift_argument, '--help']
argv.empty? ? super : Pod::Command.parse(command_needs_help)
def initialize(argv)
@help_command = Pod::Command.parse(argv) unless argv.empty?
super
end
def run
help!
help_command.help!
end
private
def help_command
@help_command || self
end
end
end
end
\ No newline at end of file
end
......@@ -6,17 +6,17 @@ module Pod
it "invokes the right command with --help flag" do
command = command('help', 'push')
command.should.be.instance_of Pod::Command::Push
lambda { command.validate! }.should.raise CLAide::Help
command.send(:help_command).should.be.instance_of Pod::Command::Push
lambda { command.run }.should.raise CLAide::Help
end
it "raises help! if no other command is passed" do
lambda { command('help').validate! }.should.raise CLAide::Help
lambda { command('help').run }.should.raise CLAide::Help
end
it "shows the right usage" do
Pod::Command::Help.arguments.should.equal '[COMMAND]'
end
end
end
\ No newline at end of file
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment