Class: Sigh::CommandsGenerator

Inherits:
Object
  • Object
show all
Includes:
Commander::Methods
Defined in:
lib/sigh/commands_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.startObject



9
10
11
12
13
14
# File 'lib/sigh/commands_generator.rb', line 9

def self.start
  FastlaneCore::UpdateChecker.start_looking_for_update('sigh')
  self.new.run
ensure
  FastlaneCore::UpdateChecker.show_update_status('sigh', Sigh::VERSION)
end

Instance Method Details

#multiple_values_option_proc(command, name) ⇒ Object



123
124
125
126
127
128
129
130
131
132
133
# File 'lib/sigh/commands_generator.rb', line 123

def multiple_values_option_proc(command, name)
  proc do |value|
    value = yield(value) if block_given?
    option = command.proxy_options.find { |opt| opt[0] == name } || []
    values = option[1] || []
    values << value

    command.proxy_options.delete option
    command.proxy_options << [name, values]
  end
end

#runObject



16
17
18
19
20
21
22
23
24
25
26
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/sigh/commands_generator.rb', line 16

def run
  program :version, Sigh::VERSION
  program :description, 'CLI for \'sigh\' - Because you would rather spend your time building stuff than fighting provisioning'
  program :help, 'Author', 'Felix Krause <[email protected]>'
  program :help, 'Website', 'https://fastlane.tools'
  program :help, 'GitHub', 'https://github.com/fastlane/sigh'
  program :help_formatter, :compact

  global_option('--verbose') { $verbose = true }

  FastlaneCore::CommanderGenerator.new.generate(Sigh::Options.available_options)

  command :renew do |c|
    c.syntax = 'sigh renew'
    c.description = 'Renews the certificate (in case it expired) and outputs the path to the generated file'

    c.action do |args, options|
      user_input = options.__hash__

      # The user might run sigh using
      #
      #   sigh development
      #
      #   sigh adhoc -u [email protected]
      #
      # When the user runs this, it will use :development
      #
      #   sigh development --adhoc
      #
      case args.first
      when "development"
        user_input[:development] = true
        user_input.delete(:adhoc)
      when "adhoc"
        user_input[:adhoc] = true
        user_input.delete(:development)
      end

      Sigh.config = FastlaneCore::Configuration.create(Sigh::Options.available_options, user_input)

      Sigh::Manager.start
    end
  end

  command :download_all do |c|
    c.syntax = 'sigh download_all'
    c.description = 'Downloads all valid provisioning profiles'

    c.action do |args, options|
      Sigh.config = FastlaneCore::Configuration.create(Sigh::Options.available_options, options.__hash__)
      Sigh::Manager.download_all
    end
  end

  command :repair do |c|
    c.syntax = 'sigh repair'
    c.description = 'Repairs all expired or invalid provisioning profiles'

    c.action do |args, options|
      Sigh.config = FastlaneCore::Configuration.create(Sigh::Options.available_options, options.__hash__)
      require 'sigh/repair'
      Sigh::Repair.new.repair_all
    end
  end

  command :resign do |c|
    c.syntax = 'sigh resign'
    c.description = 'Resigns an existing ipa file with the given provisioning profile'
    c.option '-i', '--signing_identity STRING', String, 'The signing identity to use. Must match the one defined in the provisioning profile.'
    c.option '-x', '--version_number STRING', String, 'Version number to force binary and all nested binaries to use. Changes both CFBundleShortVersionString and CFBundleIdentifier.'
    c.option '-p', '--provisioning_profile PATH', String, '(or BUNDLE_ID=PATH) The path to the provisioning profile which should be used. '\
             'Can be provided multiple times if the application contains nested applications and app extensions, which need their own provisioning profile. '\
             'The path may be prefixed with a identifier in order to determine which provisioning profile should be used on which app.',
             &multiple_values_option_proc(c, "provisioning_profile", &proc { |value| value.split('=', 2) })
    c.option '-d', '--display_name STRING', String, 'Display name to use'
    c.option '-e', '--entitlements PATH', String, 'The path to the entitlements file to use.'
    c.option '--short_version STRING', String, 'Short version string to force binary and all nested binaries to use (CFBundleShortVersionString).'
    c.option '--bundle_version STRING', String, 'Bundle version to force binary and all nested binaries to use (CFBundleVersion).'
    c.option '--use_app_entitlements', 'Extract app bundle codesigning entitlements and combine with entitlements from new provisionin profile.'
    c.option '-g', '--new_bundle_id STRING', String, 'New application bundle ID (CFBundleIdentifier)'
    c.option '--keychain_path STRING', String, 'Path to the keychain that /usr/bin/codesign should use'

    c.action do |args, options|
      Sigh::Resign.new.run(options, args)
    end
  end

  command :manage do |c|
    c.syntax = 'sigh manage'
    c.description = 'Manage installed provisioning profiles on your system.'

    c.option '-f', '--force', 'Force remove all expired provisioning profiles. Required on CI.'
    c.option '-e', '--clean_expired', 'Remove all expired provisioning profiles.'

    c.option '-p', '--clean_pattern STRING', String, 'Remove any provisioning profiles that matches the regular expression.'
    c.example 'Remove all "iOS Team Provisioning" provisioning profiles', 'sigh manage -p "iOS\ ?Team Provisioning Profile"'

    c.action do |args, options|
      Sigh::LocalManage.start(options, args)
    end
  end

  default_command :renew

  run!
end