Class: Homebrew::Cmd::Outdated Private

Inherits:
AbstractCommand show all
Defined in:
cmd/outdated.rb,
sorbet/rbi/dsl/homebrew/cmd/outdated.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

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_outdated, #pretty_uninstalled, #pretty_upgradable

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Instance Method Details

#argsHomebrew::Cmd::Outdated::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/outdated.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.

Raises:



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'cmd/outdated.rb', line 53

def run
  raise UsageError, "`--minimum-version` requires exactly one formula or cask argument." if
    minimum_version.present? && args.named.length != 1

  case json_version(args.json)
  when :v1
    odie "`brew outdated --json=v1` is no longer supported. Use brew outdated --json=v2 instead."
  when :v2, :default
    formulae, casks = if args.formula?
      [outdated_formulae, []]
    elsif args.cask?
      [[], outdated_casks]
    else
      outdated_formulae_casks
    end

    json = {
      formulae: json_info(formulae),
      casks:    json_info(casks),
    }
    # json v2.8.1 is inconsistent it how it renders empty arrays,
    # so we use `[]` for consistency:
    puts JSON.pretty_generate(json).gsub(/\[\n\n\s*\]/, "[]")

    outdated = formulae + casks
  else
    outdated = if args.formula?
      outdated_formulae
    elsif args.cask?
      outdated_casks
    else
      outdated_formulae_casks.flatten
    end

    print_outdated(outdated)
  end

  Homebrew.failed = args.named.present? && outdated.present?
end