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
autoload :Update, 'cocoapods/command/update'
class Help < Informative
def initialize(command_class, argv)
@command_class, @argv = command_class, argv
def initialize(command_class, argv, unrecognized_command = nil)
@command_class, @argv, @unrecognized_command = command_class, argv, unrecognized_command
end
def message
[
message = [
'',
@command_class.banner.gsub(/\$ pod (.*)/, '$ pod \1'.green),
'',
......@@ -30,6 +30,9 @@ module Pod
options,
"\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
private
......@@ -50,7 +53,7 @@ module Pod
end
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"
commands.each {|cmd| banner << " * $ pod #{cmd.green} --help\n"}
banner
......@@ -100,7 +103,7 @@ module Pod
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 'list' then List
when 'outdated' then Outdated
......@@ -112,8 +115,10 @@ module Pod
when 'update' then Update
end
if show_help || command_class.nil?
raise Help.new(command_class || self, argv)
if show_help
raise Help.new(command_class, argv)
elsif command_class.nil?
raise Help.new(self, argv, command_argument)
else
command_class.new(argv)
end
......
......@@ -6,7 +6,7 @@ module Pod
$ 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'.
The Xcode project file should be specified in your `Podfile` like this:
......
......@@ -2,11 +2,11 @@ module Pod
class Command
class Outdated < Command
def self.banner
%{Updates dependencies of a project:
%{Show outdated pods:
$ pod outdated
Show all of the outdated pods in the current Podfile.lock. }
Shows the outdated pods in the current Podfile.lock. }
end
def self.options
......
......@@ -2,12 +2,11 @@ module Pod
class Command
class Update < Command
def self.banner
%{Updates dependencies of a project:
%{Updating dependencies of a project:
$ pod update
Updates all dependencies installed by `pod install`. It doesn't
install new dependencies. }
Updates all dependencies.}
end
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