Class: Pod::Command

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

Direct Known Subclasses

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

Defined Under Namespace

Modules: Project Classes: Help, IPC, Init, Install, Lib, List, Outdated, 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



79
80
81
82
83
84
85
86
# File 'lib/cocoapods/command.rb', line 79

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

Class Method Details

.optionsObject



30
31
32
33
34
35
# File 'lib/cocoapods/command.rb', line 30

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

.parse(argv) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/cocoapods/command.rb', line 37

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



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

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



45
46
47
48
49
50
51
52
53
# File 'lib/cocoapods/command.rb', line 45

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

Instance Method Details

#verify_lockfile_exists!void (private)

This method returns an undefined value.

Checks that the lockfile exists.

Raises:

  • If the lockfile does not exists.



112
113
114
115
116
# File 'lib/cocoapods/command.rb', line 112

def verify_lockfile_exists!
  unless config.lockfile
    raise Informative, "No `Podfile.lock' found in the current working directory, run `pod install'."
  end
end

#verify_podfile_exists!void (private)

This method returns an undefined value.

Checks that the podfile exists.

Raises:

  • If the podfile does not exists.



100
101
102
103
104
# File 'lib/cocoapods/command.rb', line 100

def verify_podfile_exists!
  unless config.podfile
    raise Informative, "No `Podfile' found in the current working directory."
  end
end