@@ -8,18 +8,20 @@ import * as binProcessors from '../utils/processors';
88class CommandDelete extends CommandPolykey {
99 constructor ( ...args : ConstructorParameters < typeof CommandPolykey > ) {
1010 super ( ...args ) ;
11- this . name ( 'delete' ) ;
12- this . aliases ( [ 'del' , 'rm' ] ) ;
13- this . description ( 'Delete a Secret from a Specified Vault' ) ;
11+ this . name ( 'rm' ) ;
12+ this . description ( 'Delete a Secret from a specified Vault' ) ;
1413 this . argument (
15- '<secretPath>' ,
16- 'Path to the secret that to be deleted, specified as <vaultName>:<directoryPath>' ,
17- binParsers . parseSecretPathValue ,
14+ '<secretPaths...>' ,
15+ 'Path to one or more secret to be deleted, each specified as <vaultName>:<directoryPath>' ,
1816 ) ;
1917 this . addOption ( binOptions . nodeId ) ;
2018 this . addOption ( binOptions . clientHost ) ;
2119 this . addOption ( binOptions . clientPort ) ;
22- this . action ( async ( secretPath , options ) => {
20+ this . addOption ( binOptions . recursive ) ;
21+ this . action ( async ( secretPaths , options ) => {
22+ secretPaths = secretPaths . map ( ( path : string ) =>
23+ binParsers . parseSecretPathValue ( path ) ,
24+ ) ;
2325 const { default : PolykeyClient } = await import (
2426 'polykey/dist/PolykeyClient'
2527 ) ;
@@ -31,11 +33,10 @@ class CommandDelete extends CommandPolykey {
3133 this . fs ,
3234 this . logger . getChild ( binProcessors . processClientOptions . name ) ,
3335 ) ;
34- const auth = await binProcessors . processAuthentication (
36+ const meta = await binProcessors . processAuthentication (
3537 options . passwordFile ,
3638 this . fs ,
3739 ) ;
38-
3940 let pkClient : PolykeyClient ;
4041 this . exitHandlers . handlers . push ( async ( ) => {
4142 if ( pkClient != null ) await pkClient . stop ( ) ;
@@ -45,20 +46,16 @@ class CommandDelete extends CommandPolykey {
4546 nodeId : clientOptions . nodeId ,
4647 host : clientOptions . clientHost ,
4748 port : clientOptions . clientPort ,
48- options : {
49- nodePath : options . nodePath ,
50- } ,
49+ options : { nodePath : options . nodePath } ,
5150 logger : this . logger . getChild ( PolykeyClient . name ) ,
5251 } ) ;
53- await binUtils . retryAuthentication (
54- ( auth ) =>
55- pkClient . rpcClient . methods . vaultsSecretsDelete ( {
56- metadata : auth ,
57- nameOrId : secretPath [ 0 ] ,
58- secretName : secretPath [ 1 ] ,
59- } ) ,
60- auth ,
61- ) ;
52+ await binUtils . retryAuthentication ( async ( auth ) => {
53+ await pkClient . rpcClient . methods . vaultsSecretsRemove ( {
54+ metadata : auth ,
55+ secretNames : secretPaths ,
56+ options : { recursive : options . recursive } ,
57+ } ) ;
58+ } , meta ) ;
6259 } finally {
6360 if ( pkClient ! != null ) await pkClient . stop ( ) ;
6461 }
0 commit comments