Skip to content
This repository was archived by the owner on Mar 20, 2025. It is now read-only.

Commit 255f873

Browse files
committed
Implement brew bundle add
Part of #818
1 parent 949a403 commit 255f873

File tree

4 files changed

+52
-1
lines changed

4 files changed

+52
-1
lines changed

cmd/bundle.rb

+14-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def run
136136
require_relative "../lib/bundle"
137137

138138
subcommand = args.named.first.presence
139-
if subcommand != "exec" && args.named.size > 1
139+
if ["exec", "add"].exclude?(subcommand) && args.named.size > 1
140140
raise UsageError, "This command does not take more than 1 subcommand argument."
141141
end
142142

@@ -240,6 +240,19 @@ def run
240240
whalebrew: args.whalebrew? || args.all?,
241241
vscode: args.vscode? || args.all?,
242242
)
243+
when "add"
244+
_subcommand, *named_args = args.named
245+
Bundle::Commands::Add.run(
246+
*named_args,
247+
global:,
248+
file:,
249+
brews: args.brews? || args.all? || no_type_args,
250+
casks: args.casks? || args.all?,
251+
taps: args.taps? || args.all?,
252+
mas: args.mas? || args.all?,
253+
whalebrew: args.whalebrew? || args.all?,
254+
vscode: args.vscode? || args.all?,
255+
)
243256
else
244257
raise UsageError, "unknown subcommand: #{subcommand}"
245258
end

lib/bundle.rb

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
require "bundle/brewfile"
77
require "bundle/bundle"
88
require "bundle/dsl"
9+
require "bundle/adder"
910
require "bundle/checker"
1011
require "bundle/skipper"
1112
require "bundle/brew_services"
@@ -31,6 +32,7 @@
3132
require "bundle/commands/check"
3233
require "bundle/commands/exec"
3334
require "bundle/commands/list"
35+
require "bundle/commands/add"
3436
require "bundle/whalebrew_installer"
3537
require "bundle/whalebrew_dumper"
3638
require "bundle/vscode_extension_checker"

lib/bundle/adder.rb

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# typed: true
2+
# frozen_string_literal: true
3+
4+
module Bundle
5+
module Adder
6+
module_function
7+
8+
def add(*args, entries:, brews:, casks:, taps:, mas:, whalebrew:, vscode:)
9+
raise "Implement me!"
10+
end
11+
end
12+
end

lib/bundle/commands/add.rb

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# typed: true
2+
# frozen_string_literal: true
3+
4+
module Bundle
5+
module Commands
6+
module Add
7+
module_function
8+
9+
def run(*args, global:, file:, brews:, casks:, taps:, mas:, whalebrew:, vscode:)
10+
entries = Brewfile.read(global:, file:).entries
11+
Bundle::Adder.add(
12+
*args,
13+
entries:,
14+
brews:,
15+
casks:,
16+
taps:,
17+
mas:,
18+
whalebrew:,
19+
vscode:,
20+
)
21+
end
22+
end
23+
end
24+
end

0 commit comments

Comments
 (0)