Class: Pod::Command

Inherits:
Object
  • Object
show all
Includes:
Pod::Config::Mixin
Defined in:
lib/cocoapods/command.rb,
lib/cocoapods/command/repo.rb,
lib/cocoapods/command/spec.rb,
lib/cocoapods/command/setup.rb,
lib/cocoapods/command/search.rb,
lib/cocoapods/command/install.rb

Direct Known Subclasses

Install, Repo, Search, Setup, Spec

Defined Under Namespace

Classes: ARGV, Help, Install, Repo, Search, Setup, Spec

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Pod::Config::Mixin

#config

Constructor Details

#initialize(argv) ⇒ Command

Returns a new instance of Command.

Raises:



88
89
90
# File 'lib/cocoapods/command.rb', line 88

def initialize(argv)
  raise Help.new(self.class, argv)
end

Class Method Details



33
34
35
36
37
38
39
40
41
# File 'lib/cocoapods/command.rb', line 33

def self.banner
  "To see help for the available commands run:\n" \
  "\n" \
  "  * $ pod setup --help\n" \
  "  * $ pod search --help\n" \
  "  * $ pod install --help\n" \
  "  * $ pod repo --help\n" \
  "  * $ pod spec --help"
end

.optionsObject



43
44
45
46
47
48
# File 'lib/cocoapods/command.rb', line 43

def self.options
  "    --help      Show help information\n" \
  "    --silent    Print nothing\n" \
  "    --verbose   Print more information while working\n" \
  "    --version   Prints the version of CocoaPods"
end

.parse(*argv) ⇒ Object

Raises:



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/cocoapods/command.rb', line 63

def self.parse(*argv)
  argv = ARGV.new(argv)
  raise Informative, VERSION if argv.option('--version')

  show_help = argv.option('--help')
  Config.instance.silent = argv.option('--silent')
  Config.instance.verbose = argv.option('--verbose')

  command_class = case argv.shift_argument
  when 'install' then Install
  when 'repo'    then Repo
  when 'search'  then Search
  when 'setup'   then Setup
  when 'spec'    then Spec
  end

  if show_help || command_class.nil?
    raise Help.new(command_class || self, argv)
  else
    command_class.new(argv)
  end
end

.run(*argv) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/cocoapods/command.rb', line 50

def self.run(*argv)
  parse(*argv).run
rescue Exception => e
  unless e.is_a?(Informative)
    puts "Oh no, an error occurred. Please run with `--verbose' and report " \
         "on https://github.com/CocoaPods/CocoaPods/issues."
    puts ""
  end
  puts e.message
  puts *e.backtrace if Config.instance.verbose
  exit 1
end