@@ -111,24 +111,31 @@ export default defineCommand({
111111
112112 const result = await client . certificates . issue ( request ) ;
113113
114- if ( args . json ) {
115- output ( result , { json : true } ) ;
116- } else if ( args [ "out-cert" ] || args [ "out-key" ] ) {
117- // Write files if requested
118- if ( args [ "out-cert" ] ) {
119- writeFileSync ( args [ "out-cert" ] , result . certificate . certificate_pem ) ;
120- console . log ( `Certificate written to ${ args [ "out-cert" ] } ` ) ;
121- }
114+ // Write files if requested
115+ if ( args [ "out-cert" ] ) {
116+ writeFileSync ( args [ "out-cert" ] , result . certificate . certificate_pem ) ;
117+ console . log ( `Certificate written to ${ args [ "out-cert" ] } ` ) ;
118+ }
122119
123- if ( args [ "out-key" ] && result . privateKey ) {
124- writeFileSync ( args [ "out-key" ] , result . privateKey , { mode : 0o600 } ) ;
125- console . log ( `Private key written to ${ args [ "out-key" ] } ` ) ;
126- }
127- } else {
128- // Print PEM to stdout
129- console . log ( result . certificate . certificate_pem ) ;
130- if ( result . privateKey ) {
131- console . log ( result . privateKey ) ;
120+ if ( args [ "out-key" ] && result . privateKey ) {
121+ writeFileSync ( args [ "out-key" ] , result . privateKey , { mode : 0o600 } ) ;
122+ console . log ( `Private key written to ${ args [ "out-key" ] } ` ) ;
123+ }
124+
125+ // Output result (unless files were written)
126+ if ( ! args [ "out-cert" ] && ! args [ "out-key" ] ) {
127+ if ( args . json ) {
128+ output ( result , { json : true } ) ;
129+ } else {
130+ // Output formatted key-value pairs
131+ output ( {
132+ id : result . certificate . id ,
133+ commonName : result . certificate . common_name ,
134+ validFrom : result . certificate . valid_from ,
135+ validTo : result . certificate . valid_to ,
136+ certificate : result . certificate . certificate_pem ,
137+ privateKey : result . privateKey ?? "" ,
138+ } , { json : false } ) ;
132139 }
133140 }
134141 } catch ( error ) {
0 commit comments