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/push.rb,
lib/cocoapods/command/list.rb,
lib/cocoapods/command/setup.rb,
lib/cocoapods/command/search.rb,
lib/cocoapods/command/install.rb,
lib/cocoapods/command/presenter.rb,
lib/cocoapods/command/error_report.rb,
lib/cocoapods/command/presenter/cocoa_pod.rb

Direct Known Subclasses

Install, List, Push, Repo, Search, Setup, Spec

Defined Under Namespace

Modules: ErrorReport Classes: ARGV, Help, Install, List, Presenter, Push, Repo, Search, Setup, Spec

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods included from Pod::Config::Mixin

#config

Constructor Details

- (Command) initialize(argv)

A new instance of Command

Raises:



116
117
118
# File 'lib/cocoapods/command.rb', line 116

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

Class Method Details



49
50
51
52
53
54
# File 'lib/cocoapods/command.rb', line 49

def self.banner
  commands = ['install', '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
end

+ (Object) options



56
57
58
59
60
61
62
63
64
# File 'lib/cocoapods/command.rb', line 56

def self.options
  [
    ['--help',     'Show help information'],
    ['--silent',   'Print nothing'],
    ['--no-color', 'Print output without color'],
    ['--verbose',  'Print more information while working'],
    ['--version',  'Prints the version of CocoaPods'],
  ]
end

+ (Object) parse(*argv)

Raises:



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/cocoapods/command.rb', line 87

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

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

  String.send(:define_method, :colorize) { |string , _| string } if argv.option( '--no-color' )

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

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

+ (Object) run(*argv)



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

def self.run(*argv)
  sub_command = parse(*argv)
  unless ENV['SKIP_SETUP']
    Setup.new(ARGV.new).run_if_needed
  end
  sub_command.run

rescue Interrupt
  puts "[!] Cancelled".red
  Config.instance.verbose? ? raise : exit(1)

rescue Exception => e
  if e.is_a?(PlainInformative) # also catches Informative
    puts e.message
    puts *e.backtrace if Config.instance.verbose?
  else
    puts ErrorReport.report(e)
  end
  exit 1
end

Instance Method Details



130
131
132
133
134
135
136
# File 'lib/cocoapods/command.rb', line 130

def print_subtitle(title, only_verbose = false)
  if config.verbose?
    puts "\n" + title.green
  elsif !config.silent? && !only_verbose
    puts title
  end
end


122
123
124
125
126
127
128
# File 'lib/cocoapods/command.rb', line 122

def print_title(title, only_verbose = true)
  if config.verbose?
    puts "\n" + title.yellow
  elsif !config.silent? && !only_verbose
    puts title
  end
end