@@ -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,8 +137,12 @@ func execFunc(ctx *context.Context, cmd *cobra.Command, verb executable.Verb, ar
134137 envMap = make (map [string ]string )
135138 }
136139
137- setAuthEnv (ctx , cmd , e )
138- 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 )
139146 if len (textInputs ) > 0 {
140147 form , err := views .NewForm (io .Theme (ctx .Config .Theme .String ()), ctx .StdIn (), ctx .StdOut (), textInputs ... )
141148 if err != nil {
@@ -148,6 +155,8 @@ func execFunc(ctx *context.Context, cmd *cobra.Command, verb executable.Verb, ar
148155 envMap [key ] = fmt .Sprintf ("%v" , val )
149156 }
150157 }
158+
159+ setAuthEnv (ctx , cmd , e )
151160 startTime := time .Now ()
152161 eng := engine .NewExecEngine ()
153162 if err := runner .Exec (ctx , e , eng , envMap ); err != nil {
@@ -304,36 +313,43 @@ func authRequired(ctx *context.Context, rootExec *executable.Executable) bool {
304313}
305314
306315//nolint:gocognit
307- func pendingFormFields (ctx * context.Context , rootExec * executable.Executable ) []* views.FormField {
316+ func pendingFormFields (
317+ ctx * context.Context , rootExec * executable.Executable , envMap map [string ]string ,
318+ ) []* views.FormField {
308319 pending := make ([]* views.FormField , 0 )
309320 switch {
310321 case rootExec .Exec != nil :
311322 for _ , param := range rootExec .Exec .Params {
312- if param .Prompt != "" {
323+ _ , exists := envMap [param .EnvKey ]
324+ if param .Prompt != "" && ! exists {
313325 pending = append (pending , & views.FormField {Key : param .EnvKey , Title : param .Prompt })
314326 }
315327 }
316328 case rootExec .Launch != nil :
317329 for _ , param := range rootExec .Launch .Params {
318- if param .Prompt != "" {
330+ _ , exists := envMap [param .EnvKey ]
331+ if param .Prompt != "" && ! exists {
319332 pending = append (pending , & views.FormField {Key : param .EnvKey , Title : param .Prompt })
320333 }
321334 }
322335 case rootExec .Request != nil :
323336 for _ , param := range rootExec .Request .Params {
324- if param .Prompt != "" {
337+ _ , exists := envMap [param .EnvKey ]
338+ if param .Prompt != "" && ! exists {
325339 pending = append (pending , & views.FormField {Key : param .EnvKey , Title : param .Prompt })
326340 }
327341 }
328342 case rootExec .Render != nil :
329343 for _ , param := range rootExec .Render .Params {
330- if param .Prompt != "" {
344+ _ , exists := envMap [param .EnvKey ]
345+ if param .Prompt != "" && ! exists {
331346 pending = append (pending , & views.FormField {Key : param .EnvKey , Title : param .Prompt })
332347 }
333348 }
334349 case rootExec .Serial != nil :
335350 for _ , param := range rootExec .Serial .Params {
336- if param .Prompt != "" {
351+ _ , exists := envMap [param .EnvKey ]
352+ if param .Prompt != "" && ! exists {
337353 pending = append (pending , & views.FormField {Key : param .EnvKey , Title : param .Prompt })
338354 }
339355 }
@@ -343,7 +359,7 @@ func pendingFormFields(ctx *context.Context, rootExec *executable.Executable) []
343359 if err != nil {
344360 continue
345361 }
346- childPending := pendingFormFields (ctx , childExec )
362+ childPending := pendingFormFields (ctx , childExec , envMap )
347363 pending = append (pending , childPending ... )
348364 }
349365 }
@@ -359,14 +375,25 @@ func pendingFormFields(ctx *context.Context, rootExec *executable.Executable) []
359375 if err != nil {
360376 continue
361377 }
362- childPending := pendingFormFields (ctx , childExec )
378+ childPending := pendingFormFields (ctx , childExec , envMap )
363379 pending = append (pending , childPending ... )
364380 }
365381 }
366382 }
367383 return pending
368384}
369385
386+ func applyParameterOverrides (overrides []string , envMap map [string ]string ) {
387+ for _ , override := range overrides {
388+ parts := strings .SplitN (override , "=" , 2 )
389+ if len (parts ) != 2 {
390+ continue // skip invalid overrides
391+ }
392+ key , value := parts [0 ], parts [1 ]
393+ envMap [key ] = value
394+ }
395+ }
396+
370397var (
371398 //nolint:lll
372399 execDocumentation = `
0 commit comments