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 27, 2024
1 parent 5e49fb8 commit be5b6d9
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{}{}
}

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

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")

// Output options
cmd.Flags().StringVar(&runOutFormatOpt, "output-format", OutputFormatPretty, "Set the output format. Available options: pretty, json.")

Expand Down

0 comments on commit be5b6d9

Please sign in to comment.