Class: Homebrew::Cmd::Trust Private

Inherits:
AbstractCommand show all
Defined in:
cmd/trust.rb,
sorbet/rbi/dsl/homebrew/cmd/trust.rbi

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.

Defined Under Namespace

Classes: Args

Constant Summary collapse

VALID_TYPES =

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.

[:tap, :formula, :cask, :command].freeze

Instance Method Summary collapse

Methods inherited from AbstractCommand

command, command_name, dev_cmd?, #initialize, parser, ruby_cmd?

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, #opoo_without_github_actions_annotation, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_install_status, #pretty_installed, #pretty_uninstalled, #pretty_upgradable

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Instance Method Details

#argsHomebrew::Cmd::Trust::Args

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.



10
# File 'sorbet/rbi/dsl/homebrew/cmd/trust.rbi', line 10

def args; end

#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.



38
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
69
70
71
72
73
74
75
# File 'cmd/trust.rb', line 38

def run
  if args.json
    raise UsageError, "invalid JSON version: #{args.json}" if args.json != "v1"
    raise UsageError, "`--json=v1` requires no named arguments." if args.named.present?

    print_json
    return
  end

  if args.no_named?
    puts "All official taps and commands are trusted."
    printed = T.let(false, T::Boolean)
    types.each do |type|
      values = Homebrew::Trust.trusted_entries(type)
      next if values.empty?

      label = Utils.pluralize(type.to_s, 2)
      puts "Trusted #{label}:"
      values.each { |value| puts "  #{value}" }
      printed = true
    end

    puts "No trusted taps, formulae, casks or commands." unless printed
    return
  end

  args.named.each do |name|
    type, trust_name = Homebrew::Trust.target(name, type: selected_type)
    if type == :tap && !Tap.remote_reference?(trust_name) && Tap.fetch(trust_name).official?
      puts "Official tap #{trust_name} is always trusted."
      next
    end

    action = Homebrew::Trust.trust!(type, trust_name) ? "Trusted" : "Already trusted"

    puts "#{action} #{type}: #{trust_name}"
  end
end