@@ -87,6 +87,23 @@ function parseWorkflowFileType(value: string): WorkflowFileType {
8787 throw new InvalidArgumentError ( 'Expected workflow type to be one of: yaml, ts, py' ) ;
8888}
8989
90+ function parseEnvAssignment ( value : string , previous : Record < string , string > = { } ) : Record < string , string > {
91+ const equalsIndex = value . indexOf ( '=' ) ;
92+ if ( equalsIndex <= 0 ) {
93+ throw new InvalidArgumentError ( 'Expected environment assignment in KEY=VALUE form.' ) ;
94+ }
95+
96+ const key = value . slice ( 0 , equalsIndex ) . trim ( ) ;
97+ if ( ! / ^ [ A - Z a - z _ ] [ A - Z a - z 0 - 9 _ ] * $ / . test ( key ) ) {
98+ throw new InvalidArgumentError ( `Invalid environment variable name: ${ key || '(empty)' } ` ) ;
99+ }
100+
101+ return {
102+ ...previous ,
103+ [ key ] : value . slice ( equalsIndex + 1 ) ,
104+ } ;
105+ }
106+
90107function isObject ( value : unknown ) : value is Record < string , unknown > {
91108 return value !== null && typeof value === 'object' && ! Array . isArray ( value ) ;
92109}
@@ -421,6 +438,12 @@ export function registerCloudCommands(program: Command, overrides: Partial<Cloud
421438 . option ( '--timezone <timezone>' , 'IANA timezone for cron schedules' , 'UTC' )
422439 . option ( '--name <name>' , 'Schedule name' )
423440 . option ( '--description <description>' , 'Schedule description' )
441+ . option (
442+ '--env <KEY=VALUE>' ,
443+ 'Environment variable to pass to scheduled runs; repeat for multiple variables' ,
444+ parseEnvAssignment ,
445+ { }
446+ )
424447 . option ( '--json' , 'Print raw JSON response' , false )
425448 . action (
426449 async (
@@ -433,14 +456,19 @@ export function registerCloudCommands(program: Command, overrides: Partial<Cloud
433456 timezone ?: string ;
434457 name ?: string ;
435458 description ?: string ;
459+ env ?: Record < string , string > ;
436460 json ?: boolean ;
437461 }
438462 ) => {
439463 const started = Date . now ( ) ;
440464 let success = false ;
441465 let errorClass : string | undefined ;
442466 try {
443- const result = await scheduleWorkflow ( workflow , options ) ;
467+ const { env, ...scheduleOptions } = options ;
468+ const result = await scheduleWorkflow ( workflow , {
469+ ...scheduleOptions ,
470+ ...( env && Object . keys ( env ) . length > 0 ? { envSecrets : env } : { } ) ,
471+ } ) ;
444472 if ( options . json ) {
445473 deps . log ( JSON . stringify ( result , null , 2 ) ) ;
446474 } else {
0 commit comments