class Speedflow::Commands::Flow
Flow
command
Public Class Methods
add_options_from_flow(program, command)
click to toggle source
Add options from flow arguents.
program - the program. command - the command.
Returns nothing.
# File lib/speedflow/commands/flow.rb, line 72 def add_options_from_flow(program, command) config = config_from_fresh_options(program, command) flow = Speedflow::Flow.new(config) flow.flat_arguments.each do |argument| program.option( argument, '', "--#{argument} #{argument.capitalize}", String, 'Option form flow.' ) end end
init_with_program(program)
click to toggle source
Init command with program.
prog - the program.
Returns nothing.
# File lib/speedflow/commands/flow.rb, line 13 def init_with_program(program) program.command(:flow) do |command| command.syntax 'flow [trigger]' command.description 'Play with the flow, trigger some actions.' add_options_from_flow(program, command) command.action do |args, options| config = config_from_options(options) trigger = (args.first || '').to_sym process(trigger, config, args, options) end end end
invalid_trigger(trigger)
click to toggle source
Display invalid trigger message.
trigger - the trigger name.
Returns nothing.
# File lib/speedflow/commands/flow.rb, line 91 def invalid_trigger(trigger) error "Trigger not found '#{trigger}'." end
process(trigger, config, args, options)
click to toggle source
Process command.
trigger - Trigger name. config - Configuration
. args - Arguments. options - Options.
Returns nothing.
# File lib/speedflow/commands/flow.rb, line 36 def process(trigger, config, args, options) if args.empty? || !config.flow_triggers? valid_triggers(config['flow'].keys) elsif !config.flow_trigger?(trigger) invalid_trigger(trigger) valid_triggers(config['flow'].keys) else process_trigger(trigger, config, options) end end
process_trigger(trigger, config, options)
click to toggle source
Process trigger.
trigger - Trigger name. config - Configuration
. options - Options.
Returns nothing.
# File lib/speedflow/commands/flow.rb, line 54 def process_trigger(trigger, config, options) flow = Speedflow::Flow.new(config) flow.trigger(trigger, options) success "Trigger '#{trigger}' successful" rescue FlowTriggerNotFound => exception error "Trigger '#{trigger}' error: #{exception.message}" rescue Plugin::PluginNotFound => exception error "Plugin error: #{exception.message}" rescue Plugin::PluginActionNotFound => exception error exception.message end
valid_triggers(triggers)
click to toggle source
Display valid trigger message.
triggers - Array of triggers.
Returns nothing.
# File lib/speedflow/commands/flow.rb, line 100 def valid_triggers(triggers) info 'List of available triggers:' message triggers.join(', ') end