Sha256: 7b1ec5c3e14dd66f70cb540afd46dcd35a174a9b76b006e72252b194ccdb2ec2

Contents?: true

Size: 1.54 KB

Versions: 18

Compression:

Stored size: 1.54 KB

Contents

module Pantograph
  # 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)
      Pantograph.load_actions

      class_ref = Actions.action_class_ref(action)
      unless class_ref
        if Pantograph::Actions.formerly_bundled_actions.include?(action)
          # This was a formerly bundled action which is now a plugin.
          UI.verbose(caller.join("\n"))
          UI.user_error!("The action '#{action}' is no longer bundled with pantograph. You can install it using `pantograph add_plugin #{action}`")
        else
          Pantograph::ActionsList.print_suggestions(action)
          UI.user_error!("Action '#{action}' not available, run `pantograph actions` to get a full list")
        end
      end

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

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
pantograph-0.1.22 pantograph/lib/pantograph/one_off.rb
pantograph-0.1.21 pantograph/lib/pantograph/one_off.rb
pantograph-0.1.20 pantograph/lib/pantograph/one_off.rb
pantograph-0.1.19 pantograph/lib/pantograph/one_off.rb
pantograph-0.1.17 pantograph/lib/pantograph/one_off.rb
pantograph-0.1.16 pantograph/lib/pantograph/one_off.rb
pantograph-0.1.15 pantograph/lib/pantograph/one_off.rb
pantograph-0.1.14 pantograph/lib/pantograph/one_off.rb
pantograph-0.1.13 pantograph/lib/pantograph/one_off.rb
pantograph-0.1.12 pantograph/lib/pantograph/one_off.rb
pantograph-0.1.10 pantograph/lib/pantograph/one_off.rb
pantograph-0.1.8 pantograph/lib/pantograph/one_off.rb
pantograph-0.1.7 pantograph/lib/pantograph/one_off.rb
pantograph-0.1.6 pantograph/lib/pantograph/one_off.rb
pantograph-0.1.4 pantograph/lib/pantograph/one_off.rb
pantograph-0.1.3 pantograph/lib/pantograph/one_off.rb
pantograph-0.1.1 pantograph/lib/pantograph/one_off.rb
pantograph-0.1.0 pantograph/lib/pantograph/one_off.rb