Sha256: e1259ef845a238d5c7ebda820469d6a942f657090c7d481dea9e4a7f5bebb3b5

Contents?: true

Size: 1.14 KB

Versions: 5

Compression:

Stored size: 1.14 KB

Contents

module Fastlane
  # Call actions without triggering a full lane
  class OneOff
    def self.execute(args: nil)
      action_parameters = {}
      action_name = nil

      args.each do |current|
        if current.include? ":" # that's a key/value which we want to pass to the lane
          key, value = current.split(":", 2)
          UI.user_error!("Please pass values like this: key:value") unless key.length > 0
          value = CommandLineHandler.convert_value(value)
          UI.verbose("Using #{key}: #{value}")
          action_parameters[key.to_sym] = value
        else
          action_name ||= current
        end
      end

      UI.crash!("invalid syntax") unless action_name

      run(action: action_name,
          parameters: action_parameters)
    end

    def self.run(action: nil, parameters: nil)
      class_name = action.fastlane_class + 'Action'
      class_ref = nil
      begin
        class_ref = Fastlane::Actions.const_get(class_name)
      rescue NameError
        UI.crash!("Action '#{class_name}' not found")
      end

      r = Runner.new
      r.execute_action(action, class_ref, [parameters], custom_dir: '.')
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fastlane-1.87.1 lib/fastlane/one_off.rb
fastlane-1.87.0 lib/fastlane/one_off.rb
fastlane-1.86.1 lib/fastlane/one_off.rb
fastlane-1.86.0 lib/fastlane/one_off.rb
fastlane-1.85.0 lib/fastlane/one_off.rb