Sha256: 5f9c44950a6c6448da4bee48931454aed64dcb08e089835347e9b73daf64e5d1

Contents?: true

Size: 870 Bytes

Versions: 2

Compression:

Stored size: 870 Bytes

Contents

require 'commander'

module FastlaneCore
  class CommanderGenerator
    include Commander::Methods

    def generate(options)
      short_codes = []
      options.each do |option|
        appendix = (option.is_string ? "STRING" : "")
        type = (option.is_string ? String : nil)
        short_option = option.short_option || "-#{option.key.to_s[0]}"

        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"
        
        short_codes << short_option
        global_option short_option, "--#{option.key} #{appendix}", type, (option.description + " (#{option.env_name})")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fastlane_core-0.14.0 lib/fastlane_core/configuration/commander_generator.rb
fastlane_core-0.13.1 lib/fastlane_core/configuration/commander_generator.rb