Class: PDK::CLI::Exec::InteractiveCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/pdk/cli/exec/interactive_command.rb

Constant Summary

Constants inherited from Command

Command::TEMPFILE_MODE

Instance Attribute Summary

Attributes inherited from Command

#argv, #context, #environment, #exec_group, #spinner

Instance Method Summary collapse

Methods inherited from Command

#update_environment

Constructor Details

#initialize(*argv) ⇒ InteractiveCommand

rubocop :disable Lint/MissingSuper



8
9
10
11
12
13
14
15
16
# File 'lib/pdk/cli/exec/interactive_command.rb', line 8

def initialize(*argv)
  @argv = argv

  # Default to running things in the system context.
  @context = :system

  # Extra environment vars to add to base set.
  @environment = {}
end

Instance Method Details

#add_spinner(_message, _opts = {}) ⇒ Object



23
24
25
# File 'lib/pdk/cli/exec/interactive_command.rb', line 23

def add_spinner(_message, _opts = {})
  raise 'This method is not implemented for PDK::CLI::Exec::InteractiveCommand'
end

#exec_group=(_val) ⇒ Object



35
36
37
# File 'lib/pdk/cli/exec/interactive_command.rb', line 35

def exec_group=(_val)
  raise 'This method is not implemented for PDK::CLI::Exec::InteractiveCommand'
end

#execute!Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/pdk/cli/exec/interactive_command.rb', line 39

def execute!
  require 'pdk/util'

  @resolved_env = resolved_env_for_command

  if [:module, :pwd].include?(context)
    mod_root = PDK::Util.module_root

    raise PDK::CLI::FatalError, 'Current working directory is not part of a module. (No metadata.json was found.)' unless mod_root

    unless context == :pwd || Dir.pwd == mod_root
      orig_workdir = Dir.pwd
      Dir.chdir(mod_root)
    end

    result = run_process_in_clean_env!
  else
    result = run_process!
  end

  {
    interactive: true,
    stdout: nil,
    stderr: nil,
    exit_code: result[:exit_code],
    duration: result[:duration]
  }
ensure
  Dir.chdir(orig_workdir) if orig_workdir
end

#register_spinner(_spinner, _opts = {}) ⇒ Object

rubocop :enable Lint/MissingSuper



19
20
21
# File 'lib/pdk/cli/exec/interactive_command.rb', line 19

def register_spinner(_spinner, _opts = {})
  raise 'This method is not implemented for PDK::CLI::Exec::InteractiveCommand'
end

#timeoutObject



27
28
29
# File 'lib/pdk/cli/exec/interactive_command.rb', line 27

def timeout
  raise 'This method is not implemented for PDK::CLI::Exec::InteractiveCommand'
end

#timeout=(_val) ⇒ Object



31
32
33
# File 'lib/pdk/cli/exec/interactive_command.rb', line 31

def timeout=(_val)
  raise 'This method is not implemented for PDK::CLI::Exec::InteractiveCommand'
end