@@ -11,6 +11,7 @@ import (
1111 "github.com/jahvon/tuikit/views"
1212 "github.com/spf13/cobra"
1313
14+ "github.com/jahvon/flow/cmd/internal/flags"
1415 "github.com/jahvon/flow/internal/cache"
1516 "github.com/jahvon/flow/internal/context"
1617 "github.com/jahvon/flow/internal/io"
@@ -61,6 +62,7 @@ func RegisterExecCmd(ctx *context.Context, rootCmd *cobra.Command) {
6162 execFunc (ctx , cmd , verb , args )
6263 },
6364 }
65+ RegisterFlag (ctx , subCmd , * flags .ParameterValueFlag )
6466 rootCmd .AddCommand (subCmd )
6567}
6668
@@ -114,6 +116,7 @@ func execFunc(ctx *context.Context, cmd *cobra.Command, verb executable.Verb, ar
114116 ))
115117 }
116118
119+ // add args to the env map
117120 execArgs := make ([]string , 0 )
118121 if len (args ) >= 2 {
119122 execArgs = args [1 :]
@@ -134,10 +137,12 @@ func execFunc(ctx *context.Context, cmd *cobra.Command, verb executable.Verb, ar
134137 envMap = make (map [string ]string )
135138 }
136139
137- if ctx .Config .CurrentVault == nil || * ctx .Config .CurrentVault == vault .LegacyVaultReservedName {
138- setAuthEnv (ctx , cmd , e )
139- }
140- textInputs := pendingFormFields (ctx , e )
140+ // add --param overrides to the env map
141+ paramOverrides := flags .ValueFor [[]string ](ctx , cmd , * flags .ParameterValueFlag , false )
142+ applyParameterOverrides (paramOverrides , envMap )
143+
144+ // add values from the prompt param type to the env map
145+ textInputs := pendingFormFields (ctx , e , envMap )
141146 if len (textInputs ) > 0 {
142147 form , err := views .NewForm (io .Theme (ctx .Config .Theme .String ()), ctx .StdIn (), ctx .StdOut (), textInputs ... )
143148 if err != nil {
@@ -150,6 +155,10 @@ func execFunc(ctx *context.Context, cmd *cobra.Command, verb executable.Verb, ar
150155 envMap [key ] = fmt .Sprintf ("%v" , val )
151156 }
152157 }
158+
159+ if ctx .Config .CurrentVault == nil || * ctx .Config .CurrentVault == vault .LegacyVaultReservedName {
160+ setAuthEnv (ctx , cmd , e )
161+ }
153162 startTime := time .Now ()
154163 eng := engine .NewExecEngine ()
155164 if err := runner .Exec (ctx , e , eng , envMap ); err != nil {
@@ -306,36 +315,43 @@ func authRequired(ctx *context.Context, rootExec *executable.Executable) bool {
306315}
307316
308317//nolint:gocognit
309- func pendingFormFields (ctx * context.Context , rootExec * executable.Executable ) []* views.FormField {
318+ func pendingFormFields (
319+ ctx * context.Context , rootExec * executable.Executable , envMap map [string ]string ,
320+ ) []* views.FormField {
310321 pending := make ([]* views.FormField , 0 )
311322 switch {
312323 case rootExec .Exec != nil :
313324 for _ , param := range rootExec .Exec .Params {
314- if param .Prompt != "" {
325+ _ , exists := envMap [param .EnvKey ]
326+ if param .Prompt != "" && ! exists {
315327 pending = append (pending , & views.FormField {Key : param .EnvKey , Title : param .Prompt })
316328 }
317329 }
318330 case rootExec .Launch != nil :
319331 for _ , param := range rootExec .Launch .Params {
320- if param .Prompt != "" {
332+ _ , exists := envMap [param .EnvKey ]
333+ if param .Prompt != "" && ! exists {
321334 pending = append (pending , & views.FormField {Key : param .EnvKey , Title : param .Prompt })
322335 }
323336 }
324337 case rootExec .Request != nil :
325338 for _ , param := range rootExec .Request .Params {
326- if param .Prompt != "" {
339+ _ , exists := envMap [param .EnvKey ]
340+ if param .Prompt != "" && ! exists {
327341 pending = append (pending , & views.FormField {Key : param .EnvKey , Title : param .Prompt })
328342 }
329343 }
330344 case rootExec .Render != nil :
331345 for _ , param := range rootExec .Render .Params {
332- if param .Prompt != "" {
346+ _ , exists := envMap [param .EnvKey ]
347+ if param .Prompt != "" && ! exists {
333348 pending = append (pending , & views.FormField {Key : param .EnvKey , Title : param .Prompt })
334349 }
335350 }
336351 case rootExec .Serial != nil :
337352 for _ , param := range rootExec .Serial .Params {
338- if param .Prompt != "" {
353+ _ , exists := envMap [param .EnvKey ]
354+ if param .Prompt != "" && ! exists {
339355 pending = append (pending , & views.FormField {Key : param .EnvKey , Title : param .Prompt })
340356 }
341357 }
@@ -345,7 +361,7 @@ func pendingFormFields(ctx *context.Context, rootExec *executable.Executable) []
345361 if err != nil {
346362 continue
347363 }
348- childPending := pendingFormFields (ctx , childExec )
364+ childPending := pendingFormFields (ctx , childExec , envMap )
349365 pending = append (pending , childPending ... )
350366 }
351367 }
@@ -361,14 +377,25 @@ func pendingFormFields(ctx *context.Context, rootExec *executable.Executable) []
361377 if err != nil {
362378 continue
363379 }
364- childPending := pendingFormFields (ctx , childExec )
380+ childPending := pendingFormFields (ctx , childExec , envMap )
365381 pending = append (pending , childPending ... )
366382 }
367383 }
368384 }
369385 return pending
370386}
371387
388+ func applyParameterOverrides (overrides []string , envMap map [string ]string ) {
389+ for _ , override := range overrides {
390+ parts := strings .SplitN (override , "=" , 2 )
391+ if len (parts ) != 2 {
392+ continue // skip invalid overrides
393+ }
394+ key , value := parts [0 ], parts [1 ]
395+ envMap [key ] = value
396+ }
397+ }
398+
372399var (
373400 //nolint:lll
374401 execDocumentation = `
0 commit comments