Class: Pod::Command

Inherits:
CLAide::Command
  • Object
show all
Includes:
Options, Pod::Config::Mixin
Defined in:
lib/cocoapods/command.rb,
lib/cocoapods/command/env.rb,
lib/cocoapods/command/ipc.rb,
lib/cocoapods/command/lib.rb,
lib/cocoapods/command/init.rb,
lib/cocoapods/command/list.rb,
lib/cocoapods/command/repo.rb,
lib/cocoapods/command/spec.rb,
lib/cocoapods/command/cache.rb,
lib/cocoapods/command/setup.rb,
lib/cocoapods/command/update.rb,
lib/cocoapods/command/install.rb,
lib/cocoapods/command/ipc/list.rb,
lib/cocoapods/command/ipc/repl.rb,
lib/cocoapods/command/ipc/spec.rb,
lib/cocoapods/command/lib/lint.rb,
lib/cocoapods/command/outdated.rb,
lib/cocoapods/command/repo/add.rb,
lib/cocoapods/command/spec/cat.rb,
lib/cocoapods/command/repo/lint.rb,
lib/cocoapods/command/repo/list.rb,
lib/cocoapods/command/repo/push.rb,
lib/cocoapods/command/spec/edit.rb,
lib/cocoapods/command/cache/list.rb,
lib/cocoapods/command/lib/create.rb,
lib/cocoapods/command/spec/which.rb,
lib/cocoapods/command/cache/clean.rb,
lib/cocoapods/command/ipc/podfile.rb,
lib/cocoapods/command/repo/remove.rb,
lib/cocoapods/command/repo/update.rb,
lib/cocoapods/command/spec/create.rb,
lib/cocoapods/command/ipc/podfile_json.rb,
lib/cocoapods/command/options/repo_update.rb,
lib/cocoapods/command/ipc/update_search_index.rb,
lib/cocoapods/command/options/project_directory.rb

Direct Known Subclasses

Cache, Env, IPC, Init, Install, Lib, List, Outdated, Repo, Setup, Spec, Update

Defined Under Namespace

Modules: Options Classes: Cache, Env, IPC, Init, Install, Lib, List, Outdated, Repo, 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



85
86
87
88
89
90
91
92
93
# File 'lib/cocoapods/command.rb', line 85

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

Class Method Details

.git_versionGem::Version (private)

Returns a new Gem::Version based on the systems git version.

Returns:

  • (Gem::Version)


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

def self.git_version
  raw_version = Executable.capture_command('git', ['--version']).first
  match = raw_version.scan(/\d+\.\d+\.\d+/).first
  Gem::Version.new(match)
end

.optionsObject



40
41
42
43
44
# File 'lib/cocoapods/command.rb', line 40

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

.report_error(exception) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/cocoapods/command.rb', line 57

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

.run(argv) ⇒ Object



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

def self.run(argv)
  help! 'You cannot run CocoaPods as root.' if Process.uid == 0

  verify_minimum_git_version!
  verify_xcode_license_approved!

  super(argv)
ensure
  UI.print_warnings
end

.verify_minimum_git_version!void (private)

This method returns an undefined value.

Checks that the git version is at least 1.8.5

Raises:

  • If the git version is older than 1.8.5



127
128
129
130
131
# File 'lib/cocoapods/command.rb', line 127

def self.verify_minimum_git_version!
  if git_version < Gem::Version.new('1.8.5')
    raise Informative, 'You need at least git version 1.8.5 to use CocoaPods'
  end
end

.verify_xcode_license_approved!Object (private)



165
166
167
168
169
170
171
# File 'lib/cocoapods/command.rb', line 165

def self.verify_xcode_license_approved!
  if `/usr/bin/xcrun clang 2>&1` =~ /license/ && !$?.success?
    raise Informative, 'You have not agreed to the Xcode license, which ' \
      'you must do to use CocoaPods. Agree to the license by running: ' \
      '`xcodebuild -license`.'
  end
end

Instance Method Details

#ensure_master_spec_repo_exists!void

This method returns an undefined value.

Ensure that the master spec repo exists



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

def ensure_master_spec_repo_exists!
  unless config.sources_manager.master_repo_functional?
    Setup.new(CLAide::ARGV.new([])).run
  end
end

#installer_for_configInstaller (private)

Returns a new Installer parametrized from the Pod::Config.

Returns:



137
138
139
# File 'lib/cocoapods/command.rb', line 137

def installer_for_config
  Installer.new(config.sandbox, config.podfile, config.lockfile)
end

#verify_lockfile_exists!void (private)

This method returns an undefined value.

Checks that the lockfile exists.

Raises:

  • If the lockfile does not exists.



159
160
161
162
163
# File 'lib/cocoapods/command.rb', line 159

def verify_lockfile_exists!
  unless config.lockfile
    raise Informative, "No `Podfile.lock' found in the project 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.



147
148
149
150
151
# File 'lib/cocoapods/command.rb', line 147

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