Skip to content

Loading…

Added help command. Usage `pod help [COMMAND]` #957

Merged
merged 4 commits into from

3 participants

@supermarin
CocoaPods member

The old behavior is kept. You can use:

$ pod push --help
$ pod help push
$ pod help
@fabiopelosin fabiopelosin commented on an outdated diff
lib/cocoapods/command/help.rb
@@ -0,0 +1,17 @@
+module Pod
+ class Command
+ class Help < Command
+ self.summary = 'Show help for the given command'
@fabiopelosin CocoaPods member

Missing proper punctuation to terminate the sentence :smile: (this might be a clue about who implemented the annoying warning when you lint a spec).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@fabiopelosin fabiopelosin commented on the diff
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'
@fabiopelosin CocoaPods member

I think that this functionality should go in CLAide directly. Not sure though, and we could move it later on.

@alloy CocoaPods member
alloy added a note

It might be worth it to create a ticket as reminder, but I’m still on the fence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@fabiopelosin fabiopelosin commented on the diff
spec/fixtures/spec-repos/master
@@ -1 +1 @@
-Subproject commit e54bfaa54110629cbb7495a5cdbb237b1fffe8f8
+Subproject commit ee564d9da8878957e7b77cac987d9601eb04eca5
@fabiopelosin CocoaPods member

As you have update the specs repo a test is failing because new Pods/versions which affect it might have been introduced.

@supermarin CocoaPods member

:( wasn't me, I swear :smile:

Will try to rebase on origin/master before submitting again

@fabiopelosin CocoaPods member

You can keep the update and just fix the spec as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@fabiopelosin fabiopelosin commented on an outdated diff
lib/cocoapods/command/help.rb
@@ -0,0 +1,17 @@
+module Pod
+ class Command
+ class Help < 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)
@fabiopelosin CocoaPods member

I would do something like:

if argv.empty?
  super
else
  @help_command = Pod::Command.parse(argv)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@fabiopelosin fabiopelosin commented on an outdated diff
lib/cocoapods/command/help.rb
@@ -0,0 +1,17 @@
+module Pod
+ class Command
+ class Help < 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)
+ end
+
+ def run
+ help!
@fabiopelosin CocoaPods member
@help_command.help!

Currently it always shows the banner of the help subcommand.

@supermarin CocoaPods member

In fact, the self.parse returns a completely different object, so it behaves as you expect.

A different problem is that my implementation is probably a bit too implicit, and your comment is the right sign :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@fabiopelosin
CocoaPods member

:+1:

@supermarin supermarin referenced this pull request
Closed

Add pod help subcommand #949

@supermarin supermarin merged commit 2a6f800 into master
@fabiopelosin fabiopelosin deleted the help branch
@alloy
CocoaPods member

@supermarin Do you really use this? I really want to get rid of it, there should be only one way to do this imo.

/cc @irrationalfab

CocoaPods member

@alloy I don't, but the rationale was people complaining it doesn't keep conventions of other CLI tools, e.g.
git help init
bundle help exec

CocoaPods member

@supermarin Understood, but I think it’s better to have one way to do it. Also, if you want help with this pattern, you have to move the cursor back to almost the begin of the line, whereas --help can be tacked on, which seems simpler to me, no?

CocoaPods member

@alloy I believe people just type it vs adding help in the middle when a command fails.
Personally I'm a --help user, so feel free to nuke it if it'll simplify things.

CocoaPods member

:+1: For just one way to do things.

CocoaPods member

Filed #2156.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
View
3 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
View
1 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'
@fabiopelosin CocoaPods member

I think that this functionality should go in CLAide directly. Not sure though, and we could move it later on.

@alloy CocoaPods member
alloy added a note

It might be worth it to create a ticket as reminder, but I’m still on the fence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
require 'cocoapods/command/inter_process_communication'
self.abstract_command = true
View
23 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
2 spec/fixtures/spec-repos/master
@@ -1 +1 @@
-Subproject commit e54bfaa54110629cbb7495a5cdbb237b1fffe8f8
+Subproject commit ee564d9da8878957e7b77cac987d9601eb04eca5
@fabiopelosin CocoaPods member

As you have update the specs repo a test is failing because new Pods/versions which affect it might have been introduced.

@supermarin CocoaPods member

:( wasn't me, I swear :smile:

Will try to rebase on origin/master before submitting again

@fabiopelosin CocoaPods member

You can keep the update and just fix the spec as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
View
22 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
View
1 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
View
1 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
Something went wrong with that request. Please try again.