Skip to content

Commit

Permalink
feat: allow reading togomak args from TOGOMAK_ARGS
Browse files Browse the repository at this point in the history
  • Loading branch information
srevinsaju committed Nov 14, 2023
1 parent 6cddc8e commit b932ec3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cmd/togomak/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/srevinsaju/togomak/v1/internal/rules"
"github.com/urfave/cli/v2"
"os"
"strings"
)

var verboseCount = 0
Expand Down Expand Up @@ -228,8 +229,14 @@ func newConfigFromCliContext(ctx *cli.Context) ci.ConductorConfig {
hostname = "localhost"
}

args := ctx.Args().Slice()
envArgs := os.Getenv("TOGOMAK_ARGS")
if envArgs != "" {
args = append(args, strings.Split(envArgs, " ")...)
}

var stages []filter.Item
for _, stage := range ctx.Args().Slice() {
for _, stage := range args {
stages = append(stages, filter.NewFilterItem(stage))
}

Expand All @@ -240,7 +247,7 @@ func newConfigFromCliContext(ctx *cli.Context) ci.ConductorConfig {
diagWriter.WriteDiagnostics(d)
os.Exit(1)
}
filtered, d := rules.Unmarshal(ctx.Args().Slice())
filtered, d := rules.Unmarshal(args)
if d.HasErrors() {
diagWriter.WriteDiagnostics(d)
os.Exit(1)
Expand Down

0 comments on commit b932ec3

Please sign in to comment.