Skip to content

Commit

Permalink
adding feature flag to cli
Browse files Browse the repository at this point in the history
  • Loading branch information
ascandone committed Nov 26, 2024
1 parent 46c0983 commit 8f1fd3a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion internal/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ var runRawOpt string
var runStdinFlag bool
var runOutFormatOpt string

var overdraftFeatureFlag bool

type inputOpts struct {
Script string `json:"script"`
Variables map[string]string `json:"variables"`
Expand Down Expand Up @@ -115,10 +117,15 @@ func run(path string) {
os.Exit(1)
}

featureFlags := map[string]struct{}{}
if overdraftFeatureFlag {
featureFlags[interpreter.ExperimentalOverdraftFunctionFeatureFlag] = struct{}{}
}

Check warning on line 123 in internal/cmd/run.go

View check run for this annotation

Codecov / codecov/patch

internal/cmd/run.go#L120-L123

Added lines #L120 - L123 were not covered by tests

result, err := interpreter.RunProgram(context.Background(), parseResult.Value, opt.Variables, interpreter.StaticStore{
Balances: opt.Balances,
Meta: opt.Meta,
}, nil)
}, featureFlags)

Check warning on line 128 in internal/cmd/run.go

View check run for this annotation

Codecov / codecov/patch

internal/cmd/run.go#L128

Added line #L128 was not covered by tests

if err != nil {
rng := err.GetRange()
Expand Down Expand Up @@ -192,6 +199,9 @@ func getRunCmd() *cobra.Command {
cmd.Flags().StringVarP(&runRawOpt, "raw", "r", "", "Raw json input containing script, variables, balances, metadata")
cmd.Flags().BoolVar(&runStdinFlag, "stdin", false, "Take input from stdin (same format as the --raw option)")

// Feature flag
cmd.Flags().BoolVar(&overdraftFeatureFlag, interpreter.ExperimentalOverdraftFunctionFeatureFlag, false, "feature flag to enable the overdraft() function")

Check warning on line 204 in internal/cmd/run.go

View check run for this annotation

Codecov / codecov/patch

internal/cmd/run.go#L202-L204

Added lines #L202 - L204 were not covered by tests
// Output options
cmd.Flags().StringVar(&runOutFormatOpt, "output-format", OutputFormatPretty, "Set the output format. Available options: pretty, json.")

Expand Down

0 comments on commit 8f1fd3a

Please sign in to comment.