Skip to content

Commit 8fdbc63

Browse files
committed
feat: glob-expand build/clean targets
eg. ``` 🐚 ~/dev/ftl $ bit -c 'build/release/*' …/ftl-controller| $ rm -rf build/release/ftl-controller …ease/ftl-runner| $ rm -rf build/release/ftl-runner …ild/release/ftl| $ rm -rf build/release/ftl …ease/ftl-initdb| $ rm -rf build/release/ftl-initdb 🐚 ~/dev/ftl $ bit 'build/release/*' …ild/release/ftl| $ go build -o build/release/ftl -tags release -ldflags "-X main.version=v0.71.12-1-g611af4e -X main.timestamp=$(date +%s)" ./cmd/ftl …/ftl-controller| $ go build -o build/release/ftl-controller -tags release -ldflags "-X main.version=v0.71.12-1-g611af4e -X main.timestamp=$(date +%s)" ./cmd/ftl-controller …ease/ftl-initdb| $ go build -o build/release/ftl-initdb -tags release -ldflags "-X main.version=v0.71.12-1-g611af4e -X main.timestamp=$(date +%s)" ./cmd/ftl-initdb …ease/ftl-runner| $ go build -o build/release/ftl-runner -tags release -ldflags "-X main.version=v0.71.12-1-g611af4e -X main.timestamp=$(date +%s)" ./cmd/ftl-runner ```
1 parent 7c5d312 commit 8fdbc63

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

cmd/bit/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type CLI struct {
3131
List bool `short:"l" xor:"command" help:"List available targets."`
3232
Describe string `short:"D" xor:"command" help:"Describe an aspect of the Bit build. ${describe_help}" required:"" enum:"files,deps,targets,ignored" placeholder:"ASPECT"`
3333
Clean bool `short:"c" xor:"command" help:"Clean targets."`
34-
Target []string `arg:"" optional:"" help:"Target to run."`
34+
Target []string `arg:"" optional:"" help:"Targets to run (supports globbing)."`
3535
}
3636

3737
const description = `

engine/engine.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,10 @@ func (e *Engine) setTargetCleanFunc(target *Target, directive *parser.Command) e
320320
}
321321

322322
func (e *Engine) Clean(outputs []string) error {
323+
outputs, err := e.expandOutputs(outputs)
324+
if err != nil {
325+
return err
326+
}
323327
outputsSet := map[string]bool{}
324328
for _, output := range outputs {
325329
outputsSet[output] = true
@@ -379,9 +383,26 @@ func (e *Engine) Close() error {
379383
}
380384

381385
func (e *Engine) Build(outputs []string) error {
386+
outputs, err := e.expandOutputs(outputs)
387+
if err != nil {
388+
return err
389+
}
382390
return e.build(outputs, map[string]bool{})
383391
}
384392

393+
// Glob-expand outputs.
394+
func (e *Engine) expandOutputs(outputs []string) ([]string, error) {
395+
expanded := []string{}
396+
for _, output := range outputs {
397+
glob, err := e.normalisePath(output)
398+
if err != nil {
399+
return nil, err
400+
}
401+
expanded = append(expanded, e.globber.MatchFilesystem(glob)...)
402+
}
403+
return expanded, nil
404+
}
405+
385406
func (e *Engine) build(outputs []string, seen map[string]bool) error {
386407
if len(outputs) == 0 {
387408
outputs = e.Outputs()

0 commit comments

Comments
 (0)