@@ -6,7 +6,6 @@ export default class TokensRemoveCommand extends BaseCommand<typeof TokensRemove
66 static examples = [ '$ csdx auth:tokens:remove' , '$ csdx auth:tokens:remove -a <alias>' ] ;
77 static flags : FlagInput = {
88 alias : flags . string ( { char : 'a' , description : 'Alias (name) of the token to delete.' } ) ,
9- ignore : flags . boolean ( { char : 'i' , description : 'Ignores if the token is not present.' } ) ,
109 } ;
1110
1211 async run ( ) : Promise < any > {
@@ -17,21 +16,25 @@ export default class TokensRemoveCommand extends BaseCommand<typeof TokensRemove
1716 log . debug ( 'Token removal flags parsed.' , { ...this . contextDetails , flags : removeTokenFlags } ) ;
1817
1918 const alias = removeTokenFlags . alias ;
20- const ignore = removeTokenFlags . ignore ;
21- log . debug ( 'Token removal parameters set.' , { ...this . contextDetails , alias, ignore } ) ;
22-
19+ log . debug ( 'Token removal parameters set.' , { ...this . contextDetails , alias } ) ;
20+
2321 try {
2422 log . debug ( 'Retrieving token from configuration.' , { ...this . contextDetails , alias } ) ;
2523 const token = configHandler . get ( `tokens.${ alias } ` ) ;
2624 log . debug ( 'Token retrieved from configuration.' , { ...this . contextDetails , hasToken : ! ! token , tokenType : token ?. type } ) ;
27-
25+
26+ if ( alias && ! token ) {
27+ log . debug ( 'Alias provided but token not found.' , { ...this . contextDetails , alias } ) ;
28+ return cliux . print ( `No token found with alias '${ alias } '.` , { color : 'yellow' } ) ;
29+ }
30+
2831 const tokens = configHandler . get ( 'tokens' ) ;
2932 log . debug ( 'All tokens retrieved from configuration.' , { ...this . contextDetails , tokenCount : tokens ? Object . keys ( tokens ) . length : 0 } ) ;
30-
33+
3134 const tokenOptions : Array < string > = [ ] ;
32-
33- if ( token || ignore ) {
34- log . debug ( 'Token found, or ignore flag set .' , { ...this . contextDetails , hasToken : ! ! token , ignore } ) ;
35+
36+ if ( token ) {
37+ log . debug ( 'Token found.' , { ...this . contextDetails , hasToken : ! ! token } ) ;
3538 configHandler . delete ( `tokens.${ alias } ` ) ;
3639 log . debug ( 'Token removed from configuration.' , { ...this . contextDetails , alias } ) ;
3740 return cliux . success ( `CLI_AUTH_TOKENS_REMOVE_SUCCESS` ) ;
0 commit comments