Class: Legion::Cli::Function

Inherits:
Thor
  • Object
show all
Defined in:
lib/legion/cli/function.rb

Instance Method Summary collapse

Instance Method Details

#activateObject



38
# File 'lib/legion/cli/function.rb', line 38

def activate; end

#deleteObject



35
# File 'lib/legion/cli/function.rb', line 35

def delete; end

#findObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/legion/cli/function.rb', line 6

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