Class: Pod::Command

Inherits:
CLAide::Command
  • Object
show all
Includes:
Pod::Config::Mixin
Defined in:
lib/cocoapods/command.rb,
lib/cocoapods/command/help.rb,
lib/cocoapods/command/list.rb,
lib/cocoapods/command/push.rb,
lib/cocoapods/command/repo.rb,
lib/cocoapods/command/spec.rb,
lib/cocoapods/command/setup.rb,
lib/cocoapods/command/search.rb,
lib/cocoapods/command/project.rb,
lib/cocoapods/command/outdated.rb,
lib/cocoapods/command/podfile_info.rb,
lib/cocoapods/command/inter_process_communication.rb

Direct Known Subclasses

Help, IPC, Install, List, Outdated, PodfileInfo, Push, Repo, Search, Setup, Spec, Update

Defined Under Namespace

Modules: Project Classes: Help, IPC, Install, List, Outdated, PodfileInfo, Push, Repo, Search, Setup, Spec, Update

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Pod::Config::Mixin

#config

Constructor Details

#initialize(argv) ⇒ Command

TODO:

If a command is run inside another one some settings which where true might return false.

TODO:

We should probably not even load colored unless needed.

TODO:

Move silent flag to CLAide.

Note:

It is important that the commands don’t override the default settings if their flag is missing (i.e. their value is nil)

Returns a new instance of Command.



76
77
78
79
80
81
82
83
# File 'lib/cocoapods/command.rb', line 76

def initialize(argv)
  super
  config.silent = argv.flag?('silent', config.silent)
  config.verbose = self.verbose? unless self.verbose.nil?
  unless self.colorize_output?
    String.send(:define_method, :colorize) { |string , _| string }
  end
end

Class Method Details

.optionsObject



27
28
29
30
31
32
# File 'lib/cocoapods/command.rb', line 27

def self.options
  [
    ['--silent',   'Show nothing'],
    ['--version',  'Show the version of CocoaPods'],
  ].concat(super)
end

.parse(argv) ⇒ Object



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

def self.parse(argv)
  command = super
  unless SourcesManager.master_repo_functional? || command.is_a?(Setup) || command.is_a?(Repo::Add) || ENV['SKIP_SETUP']
    Setup.new(CLAide::ARGV.new([])).run
  end
  command
end

.report_error(exception) ⇒ Object



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

def self.report_error(exception)
  if exception.is_a?(Interrupt)
    puts "[!] Cancelled".red
    Config.instance.verbose? ? raise : exit(1)
  else
    if ENV['COCOA_PODS_ENV'] != 'development'
      puts UI::ErrorReport.report(exception)
      exit 1
    else
      raise exception
    end
  end
end

.run(argv) ⇒ Object



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

def self.run(argv)
  argv = CLAide::ARGV.new(argv)
  if argv.flag?('version')
    puts VERSION
    exit!(0)
  end
  super(argv)
  UI.print_warnings
end