Sha256: 218a1b57c37314228706c8f4733fe78fbd1942fec19388a2860741e874dc646e

Contents?: true

Size: 1.79 KB

Versions: 1

Compression:

Stored size: 1.79 KB

Contents

module Legion
  class Cli
    class Function < Thor
      desc 'find', 'find'
      option :internal, type: :boolean, default: false
      def find
        Legion::Service.new(cache: false, crypt: false, extensions: false, log_level: 'error')
        response = ask 'trigger extension?', limited_to: Legion::Data::Model::Extension.map(:name)
        trigger_extension = Legion::Data::Model::Extension.where(name: response).first
        runners = Legion::Data::Model::Runner.where(extension_id: trigger_extension.values[:id])
        if runners.count === 1
          trigger_runner = runners.first
          say "Auto selecting #{trigger_runner.values[:name]} since it is the only option"
        else
          response = ask 'trigger runner?', limited_to: runners.map(:name)
          trigger_runner = Legion::Data::Model::Runner.where(name: response).where(extension_id: trigger_extension.values[:id]).first
        end

        functions = Legion::Data::Model::Function.where(runner_id: trigger_runner.values[:id])

        if functions.count === 1
          trigger_function = functions.first
          say "Auto selecting #{trigger_function.values[:name]} since it is the only option"
        else
          response = ask 'trigger function?', limited_to: Legion::Data::Model::Function.where(runner_id: trigger_runner.values[:id]).map(:name)
          trigger_function = trigger_runner.functions(name: response).first
        end
        # say "#{trigger_runner.values[:namespace]}.#{trigger_function.values[:name]} selected as trigger", :green, :italicized
        # mute { trigger_function.values[:id] }
        say trigger_function.values[:id]
        # puts self.methods(false)
      end

      desc 'delete', 'delete'
      def delete; end

      desc 'activate', 'activate'
      def activate; end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
legion-cli-0.2.0 lib/legion/cli/function.rb