fastlane_core/lib/fastlane_core/configuration/commander_generator.rb
# Calls the appropriate methods for commander to show the available parameters
Calls the appropriate methods for commander to show the available parameters
Calls the appropriate methods for commander to show the available parameters
def generate(options)
      always_trace!
      used_switches = []
      options.each do |option|
        next if option.description.to_s.empty? 
        short_switch = option.short_option
        validate_short_switch(used_switches, short_switch)
        type = option.data_type
         Typically, boolean command line flags do not accept trailing values. If the flag
         is present, the value is true, if it is missing, the value is false. fastlane
         supports this style of flag. For example, you can specify a flag like `--clean`,
         and the :clean option will be true.
         However, fastlane also supports another boolean flag style that accepts trailing
         values much like options for Strings and other value types. That looks like
         `--include_bitcode false` The problem is that this does not work out of the box
         for Commander and OptionsParser. So, we need to get tricky.
         The value_appendix below acts as a placeholder in the switch definition that
         states that we expect to have a trailing value for our options. When an option
         declares a data type, we use the name of that data type in all caps like:
         "--devices ARRAY". When the data type is nil, this implies that we're going
         to be doing some special handling on that value. One special thing we do
         automatically in Configuration is to coerce special Strings into boolean values.
         If the data type is nil, the trick we do is to specify a value placeholder, but
         we wrap it in [] brackets to mark it as optional. That means that the trailing
         value may or may not be present for this flag. If the flag is present, but the
         value is not, we get a value of `true`. Perfect for the boolean flag base-case!
         If the value is there, we'll actually get it back as a String, which we can
         later coerce into a boolean.
         In this way we support handling boolean flags with or without trailing values.
        value_appendix = (type || '[VALUE]').to_s.upcase
        long_switch = "--{option.key} {value_appendix}"
        description = option.description
        description += " ({option.env_name})" unless option.env_name.to_s.empty?
         We compact this array here to remove the short_switch variable if it is nil.
         Passing a nil value to global_option has been shown to create problems with
         option parsing!
         See: https://github.com/fastlane/fastlane/tree/master/fastlane_core
         If we don't have a data type for this option, we tell it to act like a String.
         This allows us to get a reasonable value for boolean options that can be
         automatically coerced or otherwise handled by the ConfigItem for others.
        args = [short_switch, long_switch, (type || String), description].compact
         This is the call to Commander to set up the option we've been building.
        global_option(*args)
      end
    end
def generate ( options ) always_trace! used_switches = [ ] options . each do | option | next if option . description . to_s . empty? short_switch = option . short_option validate_short_switch ( used_switches , short_switch ) type = option . data_type value_appendix = ( type || '[VALUE]' ) . to_s . upcase long_switch = "--#{option.key} #{value_appendix}" description = option . description description += " (#{option.env_name})" unless option . env_name . to_s . empty? args = [ short_switch , long_switch , ( type || String ) , description ] . compact global_option ( * args ) end end
Calls the appropriate methods for commander to show the available parameters
Calls the appropriate methods for commander to show the available parameters
# First, enable `always_trace`, to show the stack trace # "private" options # This is an important bit of trickery to solve the boolean option situation. # # Typically, boolean command line flags do not accept trailing values. If the flag # is present, the value is true, if it is missing, the value is false. fastlane # supports this style of flag. For example, you can specify a flag like `--clean`, # and the :clean option will be true. # # However, fastlane also supports another boolean flag style that accepts trailing # values much like options for Strings and other value types. That looks like # `--include_bitcode false` The problem is that this does not work out of the box # for Commander and OptionsParser. So, we need to get tricky. # # The value_appendix below acts as a placeholder in the switch definition that # states that we expect to have a trailing value for our options. When an option # declares a data type, we use the name of that data type in all caps like: # "--devices ARRAY". When the data type is nil, this implies that we're going # to be doing some special handling on that value. One special thing we do # automatically in Configuration is to coerce special Strings into boolean values. # # If the data type is nil, the trick we do is to specify a value placeholder, but # we wrap it in [] brackets to mark it as optional. That means that the trailing # value may or may not be present for this flag. If the flag is present, but the # value is not, we get a value of `true`. Perfect for the boolean flag base-case! # If the value is there, we'll actually get it back as a String, which we can # later coerce into a boolean. # # In this way we support handling boolean flags with or without trailing values. # We compact this array here to remove the short_switch variable if it is nil. # Passing a nil value to global_option has been shown to create problems with # option parsing! # # See: https://github.com/fastlane/fastlane/tree/master/fastlane_core # # If we don't have a data type for this option, we tell it to act like a String. # This allows us to get a reasonable value for boolean options that can be # automatically coerced or otherwise handled by the ConfigItem for others. # This is the call to Commander to set up the option we've been building.
options
<not_specific>