lib/cli/workflow_task.rb in factor-0.1.10 vs lib/cli/workflow_task.rb in factor-0.3.1

- old
+ new

@@ -2,56 +2,46 @@ require 'cli/command' module Factor module CLI class WorkflowTask < Command - - desc "call WORKFLOW","start a workflow" - method_option :parameters, :type=>:hash, :default=>{}, :required=>false - def call(workflow_name) - puts "starting workflow #{workflow_name} with options #{options.parameters.to_s}" - - engine = Factor::Runtime::Engine.new(get_config[:email],get_config[:token]) - id = engine.send_start_workflow(workflow_name,options.parameters) - - puts "workflow executed with id #{id}" + + desc "start WORKFLOW","start listener for workflow" + def start(workflow_name) + puts @client.start_workflow(workflow_name)["notice"] end - - desc "listen WORKFLOW","start listener for workflow" - def listen(workflow_name) - puts "starting listener #{workflow_name}" - - engine = Factor::Runtime::Engine.new(get_config[:email],get_config[:token]) - engine.send_start_listener(workflow_name) - end desc "stop WORKFLOW","stop listener for workflow" def stop(workflow_name) - puts "starting listener #{workflow_name}" - - engine = Factor::Runtime::Engine.new(get_config[:email],get_config[:token]) - engine.send_stop_listener(workflow_name) + puts @client.stop_workflow(workflow_name)["notice"] end + + desc "call WORKFLOW","call workflow" + method_option :parameters, :type=>:hash, :default=>{}, :required=>false + def call(workflow_name) + puts @client.call_workflow(workflow_name,options[:parameters])["notice"] + end desc "list", "list all the workflows" - #method_option :key, :alias=>"-k", :type=>:string, :desc=>"key reference" def list - puts @client.get_workflows + @client.get_workflows().each do |workflow| + puts "#{workflow['name']} (#{workflow['slug']})" + end end - desc "add NAME FILENAME", "add a key and value for the credential" + desc "create NAME FILENAME", "add a key and value for the credential" #method_option :key, :alias=>"-k", :type=>:string, :desc=>"key reference" - #method_option :value, :alias=>"-v", :type=>:string, :desc=>"values" - def add(name,filename) + method_option :organization, :alias=>"-v", :type=>:string, :desc=>"Organizoation to which this workflow belongs" + def create(name,filename) contents=File.open(File.expand_path(filename), "rb") {|f| f.read} - puts @client.add_workflow(name,contents) + puts @client.create_workflow(name,contents,options[:organization])["notice"] end - # desc "remove NAME", "remove a workflow" - # def remove(name) - # puts @client.remove_workflow(name) - # end + desc "delete NAME", "remove a workflow" + def delete(name) + puts @client.delete_workflow(name) + end end end \ No newline at end of file