Module: Homebrew::Services::Commands::Info Private

Defined in:
services/commands/info.rb

This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module 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

Class Method Summary collapse

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:

  • hash (Hash{Symbol => T.untyped})
  • verbose (Boolean)

Returns:



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'services/commands/info.rb', line 46

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:



35
36
37
38
39
40
41
42
43
# File 'services/commands/info.rb', line 35

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

.run(targets, verbose:, json:) ⇒ void

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.

Parameters:



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'services/commands/info.rb', line 19

def self.run(targets, verbose:, json:)
  Services::Cli.check(targets)

  output = targets.map(&:to_hash)

  if json
    puts JSON.pretty_generate(output)
    return
  end

  output.each do |hash|
    puts output(hash, verbose:)
  end
end