Class: Bcome::Registry::Command::Shortcut

Inherits:
Base
  • Object
show all
Defined in:
lib/objects/registry/command/shortcut.rb

Instance Method Summary collapse

Methods inherited from Base

#defaults, #expected_keys, #initialize, is_valid_type?, #method_missing, new_from_raw_command, #process_arguments, valid_types, #validate, #validation_error

Constructor Details

This class inherits a constructor from Bcome::Registry::Command::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Bcome::Registry::Command::Base

Instance Method Details

#commandObject



24
25
26
# File 'lib/objects/registry/command/shortcut.rb', line 24

def command
  @data[:shortcut_command]
end

#execute(node, _arguments) ⇒ Object

In which the bcome context is a shortcut to a more complex command



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/objects/registry/command/shortcut.rb', line 7

def execute(node, _arguments) ## We'll add in arguments later
  begin
    if run_as_pseudo_tty?
      node.pseudo_tty command
    else
      puts "\n(#{node.namespace})$".terminal_prompt + ">\s#{command}"
      ::Bcome::Orchestrator.instance.tail_all_command_output!(node)
      node.run command
      ::Bcome::Orchestrator.instance.reset!
    end
  rescue Interrupt
    ::Bcome::Orchestrator.instance.reset!
    puts "\nExiting gracefully from interrupt\n".warning
  end
  nil
end

#run_as_pseudo_tty?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/objects/registry/command/shortcut.rb', line 28

def run_as_pseudo_tty?
  @data[:run_as_pseudo_tty]
end