@@ -74,6 +74,16 @@ function setConfigValue(config: Record<string, unknown>, key: string, value: unk
7474 config [ key ] = value ;
7575}
7676
77+ function cliOption ( options : Record < string , unknown > , key : string , aliases : string [ ] = [ ] ) : string | undefined {
78+ for ( const candidate of [ key , ...aliases ] ) {
79+ const value = options [ candidate ] ;
80+ if ( typeof value === "string" ) {
81+ return value ;
82+ }
83+ }
84+ return undefined ;
85+ }
86+
7787async function persistAndReconcile ( config : Record < string , unknown > , summary : string ) : Promise < void > {
7888 writeFileSync ( CONFIG_PATH , stringify ( config ) , "utf8" ) ;
7989 await reconfigureCmd ( ) ;
@@ -531,53 +541,54 @@ cli
531541 . option ( "--disable" , "Disable the selected integration" )
532542 . usage ( "set domains [rootDomain] | set emails | set idp local|oidc | set s3 | set syncoid" )
533543 . action ( async ( section , value , options ) => {
544+ const cliOptions = options as Record < string , unknown > ;
534545 if ( section === "domains" ) {
535546 await setDomainsCmd ( ( value as string | undefined ) || "" , {
536- manageDomain : options . manageDomain as string | undefined ,
537- lxdDomain : options . lxdDomain as string | undefined ,
538- authDomain : options . authDomain as string | undefined
547+ manageDomain : cliOption ( cliOptions , "manageDomain" ) ,
548+ lxdDomain : cliOption ( cliOptions , "lxdDomain" ) ,
549+ authDomain : cliOption ( cliOptions , "authDomain" )
539550 } ) ;
540551 return ;
541552 }
542553 if ( section === "emails" ) {
543554 await setEmailsCmd ( {
544- email : options . email as string | undefined ,
545- acmeEmail : options . acmeEmail as string | undefined ,
546- zitadelAdminEmail : options . zitadelAdminEmail as string | undefined
555+ email : cliOption ( cliOptions , "email" ) ,
556+ acmeEmail : cliOption ( cliOptions , "acmeEmail" ) ,
557+ zitadelAdminEmail : cliOption ( cliOptions , "zitadelAdminEmail" )
547558 } ) ;
548559 return ;
549560 }
550561 if ( section === "idp" ) {
551562 await setIdpCmd ( {
552563 mode : value as string ,
553- authDomain : options . authDomain as string | undefined ,
554- oidc : options . oidc as string | undefined ,
555- oidcClient : options . oidcClient as string | undefined ,
556- oidcSecret : options . oidcSecret as string | undefined ,
557- zitadelAdminEmail : options . zitadelAdminEmail as string | undefined
564+ authDomain : cliOption ( cliOptions , "authDomain" ) ,
565+ oidc : cliOption ( cliOptions , "oidc" ) ,
566+ oidcClient : cliOption ( cliOptions , "oidcClient" ) ,
567+ oidcSecret : cliOption ( cliOptions , "oidcSecret" ) ,
568+ zitadelAdminEmail : cliOption ( cliOptions , "zitadelAdminEmail" )
558569 } ) ;
559570 return ;
560571 }
561572 if ( section === "s3" ) {
562573 await setS3Cmd ( {
563- enable : Boolean ( options . enable ) ,
564- disable : Boolean ( options . disable ) ,
565- s3Endpoint : options . s3Endpoint as string | undefined ,
566- s3Bucket : options . s3Bucket as string | undefined ,
567- s3Region : options . s3Region as string | undefined ,
568- s3Prefix : options . s3Prefix as string | undefined ,
569- s3AccessKey : options . s3AccessKey as string | undefined ,
570- s3SecretKey : options . s3SecretKey as string | undefined
574+ enable : Boolean ( cliOptions . enable ) ,
575+ disable : Boolean ( cliOptions . disable ) ,
576+ s3Endpoint : cliOption ( cliOptions , " s3Endpoint" , [ "s3-endpoint" ] ) ,
577+ s3Bucket : cliOption ( cliOptions , " s3Bucket" , [ "s3-bucket" ] ) ,
578+ s3Region : cliOption ( cliOptions , " s3Region" , [ "s3-region" ] ) ,
579+ s3Prefix : cliOption ( cliOptions , " s3Prefix" , [ "s3-prefix" ] ) ,
580+ s3AccessKey : cliOption ( cliOptions , " s3AccessKey" , [ "s3-accessKey" , "s3-access-key" ] ) ,
581+ s3SecretKey : cliOption ( cliOptions , " s3SecretKey" , [ "s3-secretKey" , "s3-secret-key" ] )
571582 } ) ;
572583 return ;
573584 }
574585 if ( section === "syncoid" ) {
575586 await setSyncoidCmd ( {
576- enable : Boolean ( options . enable ) ,
577- disable : Boolean ( options . disable ) ,
578- syncoidTarget : options . syncoidTarget as string | undefined ,
579- syncoidTargetDataset : options . syncoidTargetDataset as string | undefined ,
580- syncoidSshKey : options . syncoidSshKey as string | undefined
587+ enable : Boolean ( cliOptions . enable ) ,
588+ disable : Boolean ( cliOptions . disable ) ,
589+ syncoidTarget : cliOption ( cliOptions , "syncoidTarget" ) ,
590+ syncoidTargetDataset : cliOption ( cliOptions , "syncoidTargetDataset" ) ,
591+ syncoidSshKey : cliOption ( cliOptions , "syncoidSshKey" )
581592 } ) ;
582593 return ;
583594 }
0 commit comments