Class: Homebrew::Cmd::List Private
- Inherits:
-
AbstractCommand
- Object
- AbstractCommand
- Homebrew::Cmd::List
- Includes:
- SystemCommand::Mixin
- Defined in:
- cmd/list.rb,
sorbet/rbi/dsl/homebrew/cmd/list.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
- #args ⇒ Homebrew::Cmd::List::Args private
- #run ⇒ void private
Methods included from SystemCommand::Mixin
#system_command, #system_command!
Methods inherited from AbstractCommand
command, command_name, dev_cmd?, #initialize, parser, ruby_cmd?
Constructor Details
This class inherits a constructor from Homebrew::AbstractCommand
Instance Method Details
#args ⇒ Homebrew::Cmd::List::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/list.rbi', line 10 def args; end |
#run ⇒ 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.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'cmd/list.rb', line 89 def run if args.full_name? unless args.cask? formula_names = args.no_named? ? Formula.installed : args.named.to_resolved_formulae full_formula_names = formula_names.map(&:full_name).sort(&tap_and_name_comparison) full_formula_names = Formatter.columns(full_formula_names) unless args.public_send(:"1?") puts full_formula_names if full_formula_names.present? end if args.cask? || (!args.formula? && args.no_named?) cask_names = if args.no_named? Cask::Caskroom.casks else args.named.to_formulae_and_casks(only: :cask, method: :resolve) end # The cast is because `Keg`` does not define `full_name` full_cask_names = T.cast(cask_names, T::Array[T.any(Formula, Cask::Cask)]) .map(&:full_name).sort(&tap_and_name_comparison) full_cask_names = Formatter.columns(full_cask_names) unless args.public_send(:"1?") puts full_cask_names if full_cask_names.present? end elsif args.pinned? filtered_list elsif args.versions? filtered_list unless args.cask? list_casks if args.cask? || (!args.formula? && !args.multiple? && args.no_named?) elsif args.installed_on_request? || args.installed_as_dependency? || args.poured_from_bottle? || args.built_from_source? flags = [] flags << "`--installed-on-request`" if args.installed_on_request? flags << "`--installed-as-dependency`" if args.installed_as_dependency? flags << "`--poured-from-bottle`" if args.poured_from_bottle? flags << "`--built-from-source`" if args.built_from_source? raise UsageError, "Cannot use #{flags.join(", ")} with formula arguments." unless args.no_named? formulae = if args.t? Formula.installed.sort_by { |formula| test("M", formula.rack) }.reverse! else Formula.installed.sort end formulae.reverse! if args.r? formulae.each do |formula| tab = Tab.for_formula(formula) statuses = [] statuses << "installed on request" if args.installed_on_request? && tab.installed_on_request statuses << "installed as dependency" if args.installed_as_dependency? && tab.installed_as_dependency statuses << "poured from bottle" if args.poured_from_bottle? && tab.poured_from_bottle statuses << "built from source" if args.built_from_source? && !tab.poured_from_bottle next if statuses.empty? if flags.count > 1 puts "#{formula.name}: #{statuses.join(", ")}" else puts formula.name end end elsif args.no_named? ENV["CLICOLOR"] = nil ls_args = [] ls_args << "-1" if args.public_send(:"1?") ls_args << "-l" if args.l? ls_args << "-r" if args.r? ls_args << "-t" if args.t? if !args.cask? && HOMEBREW_CELLAR.exist? && HOMEBREW_CELLAR.children.any? ohai "Formulae" if $stdout.tty? && !args.formula? safe_system "ls", *ls_args, HOMEBREW_CELLAR puts if $stdout.tty? && !args.formula? end if !args.formula? && Cask::Caskroom.any_casks_installed? ohai "Casks" if $stdout.tty? && !args.cask? safe_system "ls", *ls_args, Cask::Caskroom.path end else kegs, casks = args.named.to_kegs_to_casks if args.verbose? || !$stdout.tty? find_args = %w[-not -type d -not -name .DS_Store -print] system_command! "find", args: kegs.map(&:to_s) + find_args, print_stdout: true if kegs.present? system_command! "find", args: casks.map(&:caskroom_path) + find_args, print_stdout: true if casks.present? else kegs.each { |keg| PrettyListing.new keg } if kegs.present? Cask::List.list_casks(*casks, one: args.public_send(:"1?")) if casks.present? end end end |