@@ -16,7 +16,7 @@ async function show(options: any, _command: cmd.Command): Promise<void> {
1616
1717 let fileAlreadyExists = false ;
1818 try {
19- if ( await fs . lstat ( filename ) ) {
19+ if ( ! options . stdout && ( await fs . lstat ( filename ) ) ) {
2020 fileAlreadyExists = true ;
2121 }
2222 } catch ( err ) {
@@ -34,7 +34,8 @@ async function show(options: any, _command: cmd.Command): Promise<void> {
3434 updateSpinnerText ( `Downloading sandbox IaC template of ${ options . name } ` ) ;
3535 const bdSandbox = new BDSandbox ( { logger, authToken : token } ) ;
3636 const template = await bdSandbox . downloadTemplate ( options . name , options . version , options ?. status ?? "uploaded" ) ;
37- await fs . writeFile ( filename , template ) ;
37+ if ( options . stdout ) console . log ( template ) ;
38+ else await fs . writeFile ( filename , template ) ;
3839 spinnerSuccess ( ) ;
3940 } catch ( err : any ) {
4041 spinnerError ( err ?. message ) ;
@@ -45,6 +46,7 @@ const program = new cmd.Command("bdcli sandbox download")
4546 . addOption ( new cmd . Option ( "--name <templateName>" , "template name from listing" ) . makeOptionMandatory ( ) )
4647 . addOption ( new cmd . Option ( "--status <status>" , "Download 'uploaded' (default) or 'deployed' template" ) )
4748 . addOption ( new cmd . Option ( "--version <version>" , "Download specific version from listing" ) )
49+ . addOption ( new cmd . Option ( "--stdout" , "Spill out the template to stdout instead of writing to file" ) )
4850 . action ( async ( options , command ) => await show ( options , command ) ) ;
4951
5052( async ( ) => {
0 commit comments