Class: Homebrew::Cmd::Desc Private

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

Overview

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.

DO NOT EDIT MANUALLY This is an autogenerated file for dynamic methods in Homebrew::Cmd::Desc. Please instead update this file by running bin/tapioca dsl Homebrew::Cmd::Desc.

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::Cmd::Desc::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.



9
# File 'sorbet/rbi/dsl/homebrew/cmd/desc.rbi', line 9

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.



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
# File 'cmd/desc.rb', line 40

def run
  search_type = if args.search?
    :either
  elsif args.name?
    :name
  elsif args.description?
    :desc
  end

  if search_type.present?
    if !args.eval_all? && !Homebrew::EnvConfig.eval_all?
      raise UsageError, "`brew desc --search` needs `--eval-all` passed or `HOMEBREW_EVAL_ALL` set!"
    end

    query = args.named.join(" ")
    string_or_regex = Search.query_regexp(query)
    return Search.search_descriptions(string_or_regex, args, search_type:)
  end

  desc = {}
  args.named.to_formulae_and_casks.each do |formula_or_cask|
    case formula_or_cask
    when Formula
      desc[formula_or_cask.full_name] = formula_or_cask.desc
    when Cask::Cask
      description = formula_or_cask.desc.presence || Formatter.warning("[no description]")
      desc[formula_or_cask.full_name] = "(#{formula_or_cask.name.join(", ")}) #{description}"
    else
      raise TypeError, "Unsupported formula_or_cask type: #{formula_or_cask.class}"
    end
  end
  Descriptions.new(desc).print
end