Class: Homebrew::DevCmd::LivecheckCmd Private

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

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Instance Method Details

#argsHomebrew::DevCmd::LivecheckCmd::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/dev_cmd/livecheck_cmd.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:



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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'dev-cmd/livecheck.rb', line 51

def run
  Homebrew.install_bundler_gems!(groups: ["livecheck"])

  all = args.eval_all?

  if args.debug? && args.verbose?
    puts args
    puts Homebrew::EnvConfig.livecheck_watchlist if Homebrew::EnvConfig.livecheck_watchlist.present?
  end

  formulae_and_casks_to_check = Homebrew.with_no_api_env do
    if args.tap
      tap = Tap.fetch(T.must(args.tap))
      formulae = args.cask? ? [] : tap.formula_files.map { |path| Formulary.factory(path) }
      casks = args.formula? ? [] : tap.cask_files.map { |path| Cask::CaskLoader.load(path) }
      formulae + casks
    elsif args.installed?
      formulae = args.cask? ? [] : Formula.installed
      casks = args.formula? ? [] : Cask::Caskroom.casks
      formulae + casks
    elsif all
      formulae = args.cask? ? [] : Formula.all(eval_all: args.eval_all?)
      casks = args.formula? ? [] : Cask::Cask.all(eval_all: args.eval_all?)
      formulae + casks
    elsif args.named.present?
      args.named.to_formulae_and_casks_with_taps
    elsif File.exist?(watchlist_path)
      begin
        names = Pathname.new(watchlist_path).read.lines
                        .reject { |line| line.start_with?("#") || line.blank? }
                        .map(&:strip)

        named_args = CLI::NamedArgs.new(*names, parent: args)
        named_args.to_formulae_and_casks(ignore_unavailable: true)
      rescue Errno::ENOENT => e
        onoe e
      end
    else
      raise UsageError, "A watchlist file is required when no arguments are given."
    end
  end

  formulae_and_casks_to_check = formulae_and_casks_to_check.sort_by do |formula_or_cask|
    formula_or_cask.respond_to?(:token) ? formula_or_cask.token : formula_or_cask.name
  end

  raise UsageError, "No formulae or casks to check." if formulae_and_casks_to_check.blank?

  options = {
    json:                 args.json?,
    full_name:            args.full_name?,
    handle_name_conflict: !args.formula? && !args.cask?,
    check_resources:      args.resources?,
    newer_only:           args.newer_only?,
    extract_plist:        args.extract_plist?,
    quiet:                args.quiet?,
    debug:                args.debug?,
    verbose:              args.verbose?,
  }.compact

  Livecheck.run_checks(formulae_and_casks_to_check, **options)
end