diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fcf351f11..47402c6b9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ * CocoaPods now defines the deployment target of the Pods project computed as the minimum deployment target of the Pods libraries. [#556](https://github.com/CocoaPods/CocoaPods/issues/556) +* Added `pod help` command. You can still use the old format + with --help flag. + [#957](https://github.com/CocoaPods/CocoaPods/pull/957) ###### Bug fixes diff --git a/lib/cocoapods/command.rb b/lib/cocoapods/command.rb index 06000cec03..a2eaac19e0 100644 --- a/lib/cocoapods/command.rb +++ b/lib/cocoapods/command.rb @@ -16,6 +16,7 @@ class Command < CLAide::Command require 'cocoapods/command/search' require 'cocoapods/command/setup' require 'cocoapods/command/spec' + require 'cocoapods/command/help' require 'cocoapods/command/inter_process_communication' self.abstract_command = true diff --git a/lib/cocoapods/command/help.rb b/lib/cocoapods/command/help.rb new file mode 100644 index 0000000000..dbfd8a958c --- /dev/null +++ b/lib/cocoapods/command/help.rb @@ -0,0 +1,23 @@ +module Pod + class Command + class Help < Command + self.summary = 'Show help for the given command.' + self.arguments = '[COMMAND]' + + def initialize(argv) + @help_command = Pod::Command.parse(argv) unless argv.empty? + super + end + + def run + help_command.help! + end + + private + + def help_command + @help_command || self + end + end + end +end diff --git a/spec/fixtures/spec-repos/master b/spec/fixtures/spec-repos/master index e54bfaa541..ee564d9da8 160000 --- a/spec/fixtures/spec-repos/master +++ b/spec/fixtures/spec-repos/master @@ -1 +1 @@ -Subproject commit e54bfaa54110629cbb7495a5cdbb237b1fffe8f8 +Subproject commit ee564d9da8878957e7b77cac987d9601eb04eca5 diff --git a/spec/functional/command/help_spec.rb b/spec/functional/command/help_spec.rb new file mode 100644 index 0000000000..99e65c2ba5 --- /dev/null +++ b/spec/functional/command/help_spec.rb @@ -0,0 +1,22 @@ +require File.expand_path('../../../spec_helper', __FILE__) + +module Pod + describe "Command::Help" do + extend SpecHelper::Command + + it "invokes the right command with --help flag" do + command = command('help', 'push') + 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').run }.should.raise CLAide::Help + end + + it "shows the right usage" do + Pod::Command::Help.arguments.should.equal '[COMMAND]' + end + + end +end diff --git a/spec/unit/command_spec.rb b/spec/unit/command_spec.rb index c7bbe86d82..7f0334482a 100644 --- a/spec/unit/command_spec.rb +++ b/spec/unit/command_spec.rb @@ -3,6 +3,7 @@ module Pod describe Command do it "returns the proper command class" do + Command.parse(%w{ help }).should.be.instance_of Command::Help Command.parse(%w{ install }).should.be.instance_of Command::Install Command.parse(%w{ list }).should.be.instance_of Command::List Command.parse(%w{ outdated }).should.be.instance_of Command::Outdated diff --git a/spec/unit/resolver_spec.rb b/spec/unit/resolver_spec.rb index ddf011f480..2b3f4e0ea8 100644 --- a/spec/unit/resolver_spec.rb +++ b/spec/unit/resolver_spec.rb @@ -121,6 +121,7 @@ module Pod RestKit RestKit/JSON RestKit/Network + RestKit/ObjectMapping/Core RestKit/ObjectMapping/CoreData RestKit/ObjectMapping/JSON RestKit/UI