Commit 2c0cc3e2 authored by Fabio Pelosin's avatar Fabio Pelosin

[Command] Report unrecognized arguments in help and minor improvements.

parent 9cbb2dfd
...@@ -16,12 +16,12 @@ module Pod ...@@ -16,12 +16,12 @@ module Pod
autoload :Update, 'cocoapods/command/update' autoload :Update, 'cocoapods/command/update'
class Help < Informative class Help < Informative
def initialize(command_class, argv) def initialize(command_class, argv, unrecognized_command = nil)
@command_class, @argv = command_class, argv @command_class, @argv, @unrecognized_command = command_class, argv, unrecognized_command
end end
def message def message
[ message = [
'', '',
@command_class.banner.gsub(/\$ pod (.*)/, '$ pod \1'.green), @command_class.banner.gsub(/\$ pod (.*)/, '$ pod \1'.green),
'', '',
...@@ -30,6 +30,9 @@ module Pod ...@@ -30,6 +30,9 @@ module Pod
options, options,
"\n", "\n",
].join("\n") ].join("\n")
message << "[!] Unrecognized command: `#{@unrecognized_command}'\n".red if @unrecognized_command
message << "[!] Unrecognized argument#{@argv.count > 1 ? 's' : ''}: `#{@argv.join(' - ')}'\n".red unless @argv.empty?
message
end end
private private
...@@ -50,7 +53,7 @@ module Pod ...@@ -50,7 +53,7 @@ module Pod
end end
def self.banner def self.banner
commands = ['install', 'list', 'push', 'repo', 'search', 'setup', 'spec'].sort commands = ['install', 'update', 'outdated', 'list', 'push', 'repo', 'search', 'setup', 'spec'].sort
banner = "\nTo see help for the available commands run:\n\n" banner = "\nTo see help for the available commands run:\n\n"
commands.each {|cmd| banner << " * $ pod #{cmd.green} --help\n"} commands.each {|cmd| banner << " * $ pod #{cmd.green} --help\n"}
banner banner
...@@ -100,7 +103,7 @@ module Pod ...@@ -100,7 +103,7 @@ module Pod
String.send(:define_method, :colorize) { |string , _| string } if argv.option( '--no-color' ) String.send(:define_method, :colorize) { |string , _| string } if argv.option( '--no-color' )
command_class = case argv.shift_argument command_class = case command_argument = argv.shift_argument
when 'install' then Install when 'install' then Install
when 'list' then List when 'list' then List
when 'outdated' then Outdated when 'outdated' then Outdated
...@@ -112,8 +115,10 @@ module Pod ...@@ -112,8 +115,10 @@ module Pod
when 'update' then Update when 'update' then Update
end end
if show_help || command_class.nil? if show_help
raise Help.new(command_class || self, argv) raise Help.new(command_class, argv)
elsif command_class.nil?
raise Help.new(self, argv, command_argument)
else else
command_class.new(argv) command_class.new(argv)
end end
......
...@@ -6,7 +6,7 @@ module Pod ...@@ -6,7 +6,7 @@ module Pod
$ pod install $ pod install
Downloads all dependencies updated in `Podfile' and creates an Xcode Downloads all dependencies defined in `Podfile' and creates an Xcode
Pods library project in `./Pods'. Pods library project in `./Pods'.
The Xcode project file should be specified in your `Podfile` like this: The Xcode project file should be specified in your `Podfile` like this:
......
...@@ -2,11 +2,11 @@ module Pod ...@@ -2,11 +2,11 @@ module Pod
class Command class Command
class Outdated < Command class Outdated < Command
def self.banner def self.banner
%{Updates dependencies of a project: %{Show outdated pods:
$ pod outdated $ pod outdated
Show all of the outdated pods in the current Podfile.lock. } Shows the outdated pods in the current Podfile.lock. }
end end
def self.options def self.options
......
...@@ -2,12 +2,11 @@ module Pod ...@@ -2,12 +2,11 @@ module Pod
class Command class Command
class Update < Command class Update < Command
def self.banner def self.banner
%{Updates dependencies of a project: %{Updating dependencies of a project:
$ pod update $ pod update
Updates all dependencies installed by `pod install`. It doesn't Updates all dependencies.}
install new dependencies. }
end end
def self.options def self.options
......
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