Sha256: bb6951611207ab6a5ed0539801e72e4f2d9821a57ff15e608e30c9ecda32d385

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 KB

Contents

require 'rubygems'
require 'cli/command'

module Factor
  module CLI
    class WorkflowTask < Command

      desc "start WORKFLOW","start listener for workflow"
      def start(workflow_name)
        puts @client.start_workflow(workflow_name)["notice"]
      end

      desc "stop WORKFLOW","stop listener for workflow"
      def stop(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"
      def list
        @client.get_workflows().each do |workflow|
          puts "#{workflow['name']} (#{workflow['slug']})"
        end
      end
    
      desc "create NAME FILENAME", "add a key and value for the credential"
      #method_option :key, :alias=>"-k", :type=>:string, :desc=>"key reference"
      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.create_workflow(name,contents,options[:organization])["notice"]
      end
    
      desc "delete NAME", "remove a workflow"
      def delete(name)
        puts @client.delete_workflow(name)
      end
      
      
      
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
factor-0.3.1 lib/cli/workflow_task.rb