module CLI

Public Class Methods

chown_if_required(path) { || ... } click to toggle source
# File lib/cli.rb, line 30
def self.chown_if_required(path)
  return yield if File.owned?(path)

  puts
  puts "* 正在修改 #{path} 的所有者,之后会恢复".colorize(:light_blue)

  previous_owner = File.stat(path).uid
  system("sudo chown $(whoami) \"#{path}\"")

  raise "不能修改 #{path} 的所有者" unless File.owned?(path)

  result = yield
  system("sudo chown #{previous_owner} \"#{path}\"")
  puts "* 恢复 #{path} 的所有者".colorize(:light_blue)

  result
end
codesign_exists?() click to toggle source
# File lib/cli.rb, line 26
def self.codesign_exists?
  `which codesign` && $CHILD_STATUS.exitstatus == 0
end
dry_run?() click to toggle source
# File lib/cli.rb, line 2
def self.dry_run?
  ARGV.include?('-d') || ARGV.include?('--dry-run')
end
no_colors?() click to toggle source
# File lib/cli.rb, line 18
def self.no_colors?
  ARGV.include?('--no-colors')
end
non_interactive?() click to toggle source
# File lib/cli.rb, line 22
def self.non_interactive?
  ARGV.include?('--non-interactive')
end
restore_xcode?() click to toggle source
# File lib/cli.rb, line 10
def self.restore_xcode?
  ARGV.include?('--restore')
end
unsign_xcode?() click to toggle source
# File lib/cli.rb, line 6
def self.unsign_xcode?
  ARGV.include?('--unsign')
end
update_plugins?() click to toggle source
# File lib/cli.rb, line 14
def self.update_plugins?
  ARGV.include?('--update_plugins')
end

Public Instance Methods

separator() click to toggle source
# File lib/cli.rb, line 62
def separator
  puts
end