Class: Luffa::CLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/luffa/cli/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/luffa/cli/cli.rb', line 17

def self.exit_on_failure?
  true
end

Instance Method Details

#authorizeObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/luffa/cli/cli.rb', line 27

def authorize
  this_dir = File.dirname(__FILE__)
  relative_path = File.join(this_dir, '..', '..', '..', 'script', 'ci')
  plist_path = File.expand_path(relative_path)

  analysis_plist = "#{plist_path}/com.apple.dt.instruments.process.analysis.plist"
  kill_plist = "#{plist_path}/com.apple.dt.instruments.process.kill.plist"

  analysis_domain = 'com.apple.dt.instruments.process.analysis'
  analysis_args = ['security', 'authorizationdb', 'write', analysis_domain]

  kill_domain = 'com.apple.dt.instruments.process.kill'
  kill_args = ['security', 'authorizationdb', 'write', kill_domain]

  if Luffa::Environment.travis_ci?
    cmd = "sudo #{analysis_args.join(' ')} < \"#{analysis_plist}\""
    options = {
          :pass_msg => 'Wrote analysis.plist',
          :fail_msg => 'Could not write analysis.plist',
          :exit_on_nonzero_status => false
    }
    analysis_code = Luffa.unix_command(cmd, options)

    cmd = "sudo #{kill_args.join(' ')} < \"#{kill_plist}\""
    options = {
          :pass_msg => 'Wrote kill.plist',
          :fail_msg => 'Could not write kill.plist',
          :exit_on_nonzero_status => false
    }

    kill_code = Luffa.unix_command(cmd, options)
    analysis_code == 0 && kill_code == 0
  else
    puts "Skipping 'security authorizationdb write' because it requires sudo"
    true
  end
end

#versionObject



22
23
24
# File 'lib/luffa/cli/cli.rb', line 22

def version
  puts Luffa::VERSION
end