@@ -239,36 +239,32 @@ def run
239
239
whalebrew : args . whalebrew? || args . all? ,
240
240
vscode : args . vscode? || args . all? ,
241
241
)
242
- when "add"
243
- raise UsageError , "`add` does not support `--mas`." if args . mas?
244
-
245
- # We intentionally omit the `s` from `brews` and `casks` for ease of handling later.
246
- type_hash = {
247
- brew : args . brews? || no_type_args ,
248
- cask : args . casks? ,
249
- whalebrew : args . whalebrew? ,
250
- vscode : args . vscode? ,
251
- }
252
- selected_types = type_hash . select { |_ , v | v } . keys
253
- raise UsageError , "`add` supports only one type of entry at a time." if selected_types . count > 1
254
-
255
- _subcommand , *named_args = args . named
256
- Bundle ::Commands ::Add . run ( *named_args , type : selected_types . first , global :, file :)
257
- when "remove"
258
- # We intentionally omit the `s` from `brews` and `casks` for ease of handling later.
242
+ when "add" , "remove"
243
+ # We intentionally omit the `s` from `brews`, `casks`, and `taps` for ease of handling later.
259
244
type_hash = {
260
245
brew : args . brews? ,
261
246
cask : args . casks? ,
247
+ tap : args . taps? ,
262
248
mas : args . mas? ,
263
249
whalebrew : args . whalebrew? ,
264
250
vscode : args . vscode? ,
265
251
none : no_type_args ,
266
252
}
267
253
selected_types = type_hash . select { |_ , v | v } . keys
268
- raise UsageError , "`remove` requires exactly one type of entry." if selected_types . count != 1
254
+ raise UsageError , "`#{ subcommand } ` supports only one type of entry at a time ." if selected_types . count != 1
269
255
270
256
_ , *named_args = args . named
271
- Bundle ::Commands ::Remove . run ( *named_args , type : selected_types . first , global :, file :)
257
+ if subcommand == "add"
258
+ type = case ( t = selected_types . first )
259
+ when :none then :brew
260
+ when :mas then raise UsageError , "`add` does not support `--mas`."
261
+ else t
262
+ end
263
+
264
+ Bundle ::Commands ::Add . run ( *named_args , type :, global :, file :)
265
+ else
266
+ Bundle ::Commands ::Remove . run ( *named_args , type : selected_types . first , global :, file :)
267
+ end
272
268
else
273
269
raise UsageError , "unknown subcommand: #{ subcommand } "
274
270
end
0 commit comments