Class: Nvoi::Cli::Exec::Command
- Inherits:
-
Object
- Object
- Nvoi::Cli::Exec::Command
- Defined in:
- lib/nvoi/cli/exec/command.rb
Overview
Command handles remote command execution on servers
Instance Method Summary collapse
-
#initialize(options) ⇒ Command
constructor
A new instance of Command.
- #run(args) ⇒ Object
Constructor Details
#initialize(options) ⇒ Command
Returns a new instance of Command.
8 9 10 11 |
# File 'lib/nvoi/cli/exec/command.rb', line 8 def initialize() = @log = Nvoi.logger end |
Instance Method Details
#run(args) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/nvoi/cli/exec/command.rb', line 13 def run(args) @log.info "Exec CLI %s", VERSION # Load configuration config_path = resolve_config_path @config = Utils::ConfigLoader.load(config_path) # Apply branch override if specified apply_branch_override if [:branch] # Initialize cloud provider @provider = External::Cloud.for(@config) if [:interactive] @log.warning "Ignoring command arguments in interactive mode" unless args.empty? @log.warning "Ignoring --all flag in interactive mode" if [:all] open_shell([:server]) else raise ArgumentError, "command required (use --interactive/-i for shell)" if args.empty? command = args.join(" ") if [:all] run_all(command) else run_on_server(command, [:server]) end end end |