Class: Ace::Overseer::CLI::Commands::Status

Inherits:
Support::Cli::Command
  • Object
show all
Includes:
Support::Cli::Base
Defined in:
lib/ace/overseer/cli/commands/status.rb

Instance Method Summary collapse

Constructor Details

#initialize(collector: nil, config: nil, lab_client: nil) ⇒ Status

Returns a new instance of Status.



21
22
23
24
25
26
# File 'lib/ace/overseer/cli/commands/status.rb', line 21

def initialize(collector: nil, config: nil, lab_client: nil)
  super()
  @collector = collector || Organisms::StatusCollector.new
  @config = config
  @lab_client = lab_client || Molecules::LabClient.new
end

Instance Method Details

#call(format:, runtime: "tmux", project: nil, **options) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/ace/overseer/cli/commands/status.rb', line 28

def call(format:, runtime: "tmux", project: nil, **options)
  if runtime == "lab"
    if options[:watch]
      raise Ace::Support::Cli::Error, "Lab watch runs in the project Herdr status pane; omit --watch"
    end
    arguments = ["work", "status"]
    arguments.concat(["--project", project]) unless project.to_s.empty?
    arguments << "--json" if format == "json"
    output = @lab_client.call(*arguments, json: false)
    puts output unless options[:quiet]
    return
  end
  raise Ace::Support::Cli::Error, "unsupported runtime: #{runtime}" unless runtime == "tmux"

  Atoms::RepoGuard.ensure_repo!
  return if options[:quiet]

  if options[:watch] && format != "json"
    run_watch_loop(format, options)
  else
    run_once(format)
  end
rescue Interrupt
  nil
rescue => e
  raise Ace::Support::Cli::Error.new(e.message)
end