Skip to content

Commit e4dbc27

Browse files
committed
feat: using logger for agent shutdown messages
chore: change command for vaults delete to be rm|remove fix: updated tests fix: removed touch alias for vaults create
1 parent 740c72d commit e4dbc27

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

src/agent/CommandStart.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ class CommandStart extends CommandPolykey {
253253
pkAgent.addEventListener(
254254
polykeyEvents.EventPolykeyAgentStop.name,
255255
() => {
256-
process.stderr.write('Stopping Agent\n');
256+
this.logger.warn('Stopping Agent');
257257
},
258258
{ once: true },
259259
);

src/agent/CommandStop.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ class CommandStop extends CommandPolykey {
2727
);
2828
const statusInfo = clientStatus.statusInfo;
2929
if (statusInfo?.status === 'DEAD') {
30-
process.stderr.write('Agent is already dead\n');
30+
this.logger.warn('Agent is already dead');
3131
return;
3232
} else if (statusInfo?.status === 'STOPPING') {
33-
process.stderr.write('Agent is already stopping\n');
33+
this.logger.warn('Agent is already stopping');
3434
return;
3535
} else if (statusInfo?.status === 'STARTING') {
3636
throw new errors.ErrorPolykeyCLIAgentStatus('Agent is starting');
@@ -62,7 +62,7 @@ class CommandStop extends CommandPolykey {
6262
}),
6363
auth,
6464
);
65-
process.stderr.write('Stopping Agent\n');
65+
this.logger.warn('Stopping Agent');
6666
} finally {
6767
if (pkClient! != null) await pkClient.stop();
6868
}

src/vaults/CommandCreate.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ class CommandCreate extends CommandPolykey {
1010
constructor(...args: ConstructorParameters<typeof CommandPolykey>) {
1111
super(...args);
1212
this.name('create');
13-
this.aliases(['touch']);
1413
this.description('Create a new Vault');
1514
this.argument(
1615
'<vaultName>',
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ import * as binParsers from '../utils/parsers';
88
class CommandDelete extends CommandPolykey {
99
constructor(...args: ConstructorParameters<typeof CommandPolykey>) {
1010
super(...args);
11-
this.name('delete');
12-
this.description('Delete an Existing Vault');
11+
this.name('rm');
12+
this.alias('remove');
13+
this.description('Remove an existing Vault');
1314
this.argument(
1415
'<vaultName>',
15-
'Name of the vault to be deleted',
16+
'Name of the vault to be removed',
1617
binParsers.parseVaultName,
1718
);
1819
this.addOption(binOptions.nodeId);

src/vaults/CommandVaults.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import CommandClone from './CommandClone';
22
import CommandCreate from './CommandCreate';
3-
import CommandDelete from './CommandDelete';
43
import CommandList from './CommandList';
54
import CommandLog from './CommandLog';
65
import CommandScan from './CommandScan';
76
import CommandPermissions from './CommandPermissions';
87
import CommandPull from './CommandPull';
8+
import CommandRemove from './CommandRemove';
99
import CommandRename from './CommandRename';
1010
import CommandShare from './CommandShare';
1111
import CommandUnshare from './CommandUnshare';
@@ -19,11 +19,11 @@ class CommandVaults extends CommandPolykey {
1919
this.description('Vaults Operations');
2020
this.addCommand(new CommandClone(...args));
2121
this.addCommand(new CommandCreate(...args));
22-
this.addCommand(new CommandDelete(...args));
2322
this.addCommand(new CommandList(...args));
2423
this.addCommand(new CommandLog(...args));
2524
this.addCommand(new CommandPermissions(...args));
2625
this.addCommand(new CommandPull(...args));
26+
this.addCommand(new CommandRemove(...args));
2727
this.addCommand(new CommandRename(...args));
2828
this.addCommand(new CommandShare(...args));
2929
this.addCommand(new CommandUnshare(...args));
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as ids from 'polykey/dist/ids';
88
import * as keysUtils from 'polykey/dist/keys/utils';
99
import * as testUtils from '../utils';
1010

11-
describe('commandDeleteVault', () => {
11+
describe('commandRemoveVault', () => {
1212
const password = 'password';
1313
const logger = new Logger('CLI Test', LogLevel.WARN, [new StreamHandler()]);
1414
let dataDir: string;
@@ -68,8 +68,8 @@ describe('commandDeleteVault', () => {
6868
});
6969
});
7070

71-
test('should delete vault', async () => {
72-
command = ['vaults', 'delete', '-np', dataDir, vaultName];
71+
test('should remove vault', async () => {
72+
command = ['vaults', 'rm', '-np', dataDir, vaultName];
7373
await polykeyAgent.vaultManager.createVault(vaultName);
7474
let id = polykeyAgent.vaultManager.getVaultId(vaultName);
7575
expect(id).toBeTruthy();

0 commit comments

Comments
 (0)