Class: Homebrew::Cmd::Bundle Private
- Inherits:
-
AbstractCommand
- Object
- AbstractCommand
- Homebrew::Cmd::Bundle
- Defined in:
- cmd/bundle.rb,
sorbet/rbi/dsl/homebrew/cmd/bundle.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::Bundle::Args private
- #run ⇒ void private
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::Bundle::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/bundle.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.
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 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
# File 'cmd/bundle.rb', line 133 def run # Keep this inside `run` to keep --help fast. require "bundle" subcommand = args.named.first.presence if %w[exec add remove].exclude?(subcommand) && args.named.size > 1 raise UsageError, "This command does not take more than 1 subcommand argument." end global = args.global? file = args.file args.zap? no_upgrade = if args.upgrade? || subcommand == "upgrade" false else args.no_upgrade? end verbose = args.verbose? force = args.force? zap = args.zap? no_type_args = !args.brews? && !args.casks? && !args.taps? && !args.mas? && !args.whalebrew? && !args.vscode? if args.install? if [nil, "install", "upgrade"].include?(subcommand) raise UsageError, "`--install` cannot be used with `install`, `upgrade` or no subcommand." end require "bundle/commands/install" redirect_stdout($stderr) do Homebrew::Bundle::Commands::Install.run(global:, file:, no_upgrade:, verbose:, force:, quiet: true) end end case subcommand when nil, "install", "upgrade" require "bundle/commands/install" Homebrew::Bundle::Commands::Install.run(global:, file:, no_upgrade:, verbose:, force:, quiet: args.quiet?) cleanup = if ENV.fetch("HOMEBREW_BUNDLE_INSTALL_CLEANUP", nil) args.global? else args.cleanup? end if cleanup require "bundle/commands/cleanup" Homebrew::Bundle::Commands::Cleanup.run( global:, file:, zap:, force: true, dsl: Homebrew::Bundle::Commands::Install.dsl ) end when "dump" vscode = if args.no_vscode? false elsif args.vscode? true else no_type_args end require "bundle/commands/dump" Homebrew::Bundle::Commands::Dump.run( global:, file:, force:, describe: args.describe?, no_restart: args.no_restart?, taps: args.taps? || no_type_args, brews: args.brews? || no_type_args, casks: args.casks? || no_type_args, mas: args.mas? || no_type_args, whalebrew: args.whalebrew? || no_type_args, vscode: ) when "edit" require "bundle/brewfile" exec_editor(Homebrew::Bundle::Brewfile.path(global:, file:)) when "cleanup" require "bundle/commands/cleanup" Homebrew::Bundle::Commands::Cleanup.run(global:, file:, force:, zap:) when "check" require "bundle/commands/check" Homebrew::Bundle::Commands::Check.run(global:, file:, no_upgrade:, verbose:) when "exec", "sh", "env" named_args = case subcommand when "exec" _subcommand, *named_args = args.named named_args when "sh" preferred_path = Utils::Shell.preferred_path(default: "/bin/bash") notice = unless Homebrew::EnvConfig.no_env_hints? <<~EOS Your shell has been configured to use a build environment from your `Brewfile`. This should help you build stuff. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`). When done, type `exit`. EOS end ENV["HOMEBREW_FORCE_API_AUTO_UPDATE"] = nil [Utils::Shell.shell_with_prompt("brew bundle", preferred_path:, notice:)] when "env" ["env"] end require "bundle/commands/exec" Homebrew::Bundle::Commands::Exec.run(*named_args, global:, file:, subcommand:, services: args.services?) when "list" require "bundle/commands/list" Homebrew::Bundle::Commands::List.run( global:, file:, brews: args.brews? || args.all? || no_type_args, casks: args.casks? || args.all?, taps: args.taps? || args.all?, mas: args.mas? || args.all?, whalebrew: args.whalebrew? || args.all?, vscode: args.vscode? || args.all?, ) when "add", "remove" # We intentionally omit the `s` from `brews`, `casks`, and `taps` for ease of handling later. type_hash = { brew: args.brews?, cask: args.casks?, tap: args.taps?, mas: args.mas?, whalebrew: args.whalebrew?, vscode: args.vscode?, none: no_type_args, } selected_types = type_hash.select { |_, v| v }.keys raise UsageError, "`#{subcommand}` supports only one type of entry at a time." if selected_types.count != 1 _, *named_args = args.named if subcommand == "add" type = case (t = selected_types.first) when :none then :brew when :mas then raise UsageError, "`add` does not support `--mas`." else t end require "bundle/commands/add" Homebrew::Bundle::Commands::Add.run(*named_args, type:, global:, file:) else require "bundle/commands/remove" Homebrew::Bundle::Commands::Remove.run(*named_args, type: selected_types.first, global:, file:) end else raise UsageError, "unknown subcommand: #{subcommand}" end end |