Class: Homebrew::Cmd::Services::InfoSubcommand Private

Inherits:
AbstractSubcommand show all
Defined in:
services/subcommand/info.rb

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Constant Summary collapse

TRIGGERS =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

%w[info i].freeze

Instance Attribute Summary

Attributes inherited from AbstractSubcommand

#args, #cleanup, #context, #quiet, #targets

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractSubcommand

define, define_all, #initialize, subcommand_name, subcommands_for

Methods included from Utils::Output::Mixin

#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_install_status, #pretty_installed, #pretty_outdated, #pretty_uninstalled, #pretty_upgradable

Constructor Details

This class inherits a constructor from Homebrew::AbstractSubcommand

Class Method Details

.output(hash, verbose:) ⇒ String

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

Returns:



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'services/subcommand/info.rb', line 53

def self.output(hash, verbose:)
  out = "#{Tty.bold}#{hash[:name]}#{Tty.reset} (#{hash[:service_name]})\n"
  out += "Running: #{pretty_bool(hash[:running])}\n"
  out += "Loaded: #{pretty_bool(hash[:loaded])}\n"
  out += "Schedulable: #{pretty_bool(hash[:schedulable])}\n"
  out += "User: #{hash[:user]}\n" unless hash[:pid].nil?
  out += "PID: #{hash[:pid]}\n" unless hash[:pid].nil?
  return out unless verbose

  out += "File: #{hash[:file]} #{pretty_bool(hash[:file].present?)}\n"
  out += "Registered at login: #{pretty_bool(hash[:registered])}\n"
  out += "Command: #{hash[:command]}\n" unless hash[:command].nil?
  out += "Working directory: #{hash[:working_dir]}\n" unless hash[:working_dir].nil?
  out += "Root directory: #{hash[:root_dir]}\n" unless hash[:root_dir].nil?
  out += "Log: #{hash[:log_path]}\n" unless hash[:log_path].nil?
  out += "Error log: #{hash[:error_log_path]}\n" unless hash[:error_log_path].nil?
  out += "Interval: #{hash[:interval]}s\n" unless hash[:interval].nil?
  out += "Cron: #{hash[:cron]}\n" unless hash[:cron].nil?

  out
end

.pretty_bool(bool) ⇒ String

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

Returns:



42
43
44
45
46
47
48
49
50
# File 'services/subcommand/info.rb', line 42

def self.pretty_bool(bool)
  return bool.to_s if !$stdout.tty? || Homebrew::EnvConfig.no_emoji?

  if bool
    "#{Tty.bold}#{Formatter.success("")}#{Tty.reset}"
  else
    "#{Tty.bold}#{Formatter.error("")}#{Tty.reset}"
  end
end

Instance Method Details

#runvoid

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'services/subcommand/info.rb', line 24

def run
  Homebrew::Services::Cli.check!(targets)

  output = targets.map(&:to_hash)

  if args.json?
    puts JSON.pretty_generate(output)
    return
  end

  output.each do |hash|
    puts self.class.output(hash, verbose: args.verbose?)
  end
end