Class: FastlaneCore::CommanderGenerator

Inherits:
Object
  • Object
show all
Includes:
Commander::Methods
Defined in:
lib/fastlane_core/configuration/commander_generator.rb

Instance Method Summary collapse

Instance Method Details

#generate(options) ⇒ Object

Calls the appropriate methods for commander to show the available parameters



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fastlane_core/configuration/commander_generator.rb', line 8

def generate(options)
  # First, enable `always_trace`, to show the stack trace
  always_trace!

  short_codes = []
  options.each do |option|
    appendix = (option.is_string ? "STRING" : "")
    type = (option.is_string ? String : nil)
    short_option = option.short_option

    raise "Short option #{short_option} already taken for key #{option.key}".red if short_codes.include? short_option
    raise "-v is already used for the version (key #{option.key})".red if short_option == "-v"
    raise "-h is already used for the help screen (key #{option.key})".red if short_option == "-h"
    raise "-t is already used for the trace screen (key #{option.key})".red if short_option == "-t"

    short_codes << short_option if short_option

    # Example Call
    # c.option '-p', '--pattern STRING', String, 'Description'

    flag = "--#{option.key} #{appendix}"
    description = option.description
    description += " (#{option.env_name})" if option.env_name.to_s.length > 0

    global_option short_option, flag, type, description
  end
end