Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using logger methods for agent shutdown messaging #328

Open
wants to merge 3 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/agent/CommandStart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class CommandStart extends CommandPolykey {
pkAgent.addEventListener(
polykeyEvents.EventPolykeyAgentStop.name,
() => {
process.stderr.write('Stopping Agent\n');
this.logger.warn('Stopping Agent');
},
{ once: true },
);
Expand Down
6 changes: 3 additions & 3 deletions src/agent/CommandStop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ class CommandStop extends CommandPolykey {
);
const statusInfo = clientStatus.statusInfo;
if (statusInfo?.status === 'DEAD') {
process.stderr.write('Agent is already dead\n');
this.logger.warn('Agent is already dead');
return;
} else if (statusInfo?.status === 'STOPPING') {
process.stderr.write('Agent is already stopping\n');
this.logger.warn('Agent is already stopping');
return;
} else if (statusInfo?.status === 'STARTING') {
throw new errors.ErrorPolykeyCLIAgentStatus('Agent is starting');
Expand Down Expand Up @@ -62,7 +62,7 @@ class CommandStop extends CommandPolykey {
}),
auth,
);
process.stderr.write('Stopping Agent\n');
this.logger.warn('Stopping Agent');
} finally {
if (pkClient! != null) await pkClient.stop();
}
Expand Down
2 changes: 1 addition & 1 deletion src/vaults/CommandCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class CommandCreate extends CommandPolykey {
constructor(...args: ConstructorParameters<typeof CommandPolykey>) {
super(...args);
this.name('create');
this.aliases(['touch']);
this.alias('touch');
this.description('Create a new Vault');
this.argument(
'<vaultName>',
Expand Down
7 changes: 4 additions & 3 deletions src/vaults/CommandDelete.ts → src/vaults/CommandRemove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import * as binParsers from '../utils/parsers';
class CommandDelete extends CommandPolykey {
constructor(...args: ConstructorParameters<typeof CommandPolykey>) {
super(...args);
this.name('delete');
this.description('Delete an Existing Vault');
this.name('rm');
this.alias('remove');
this.description('Remove an existing Vault');
this.argument(
'<vaultName>',
'Name of the vault to be deleted',
'Name of the vault to be removed',
binParsers.parseVaultName,
);
this.addOption(binOptions.nodeId);
Expand Down
4 changes: 2 additions & 2 deletions src/vaults/CommandVaults.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import CommandClone from './CommandClone';
import CommandCreate from './CommandCreate';
import CommandDelete from './CommandDelete';
import CommandList from './CommandList';
import CommandLog from './CommandLog';
import CommandScan from './CommandScan';
import CommandPermissions from './CommandPermissions';
import CommandPull from './CommandPull';
import CommandRemove from './CommandRemove';
import CommandRename from './CommandRename';
import CommandShare from './CommandShare';
import CommandUnshare from './CommandUnshare';
Expand All @@ -19,11 +19,11 @@ class CommandVaults extends CommandPolykey {
this.description('Vaults Operations');
this.addCommand(new CommandClone(...args));
this.addCommand(new CommandCreate(...args));
this.addCommand(new CommandDelete(...args));
this.addCommand(new CommandList(...args));
this.addCommand(new CommandLog(...args));
this.addCommand(new CommandPermissions(...args));
this.addCommand(new CommandPull(...args));
this.addCommand(new CommandRemove(...args));
this.addCommand(new CommandRename(...args));
this.addCommand(new CommandShare(...args));
this.addCommand(new CommandUnshare(...args));
Expand Down
6 changes: 3 additions & 3 deletions tests/vaults/delete.test.ts → tests/vaults/remove.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as ids from 'polykey/dist/ids';
import * as keysUtils from 'polykey/dist/keys/utils';
import * as testUtils from '../utils';

describe('commandDeleteVault', () => {
describe('commandRemoveVault', () => {
const password = 'password';
const logger = new Logger('CLI Test', LogLevel.WARN, [new StreamHandler()]);
let dataDir: string;
Expand Down Expand Up @@ -68,8 +68,8 @@ describe('commandDeleteVault', () => {
});
});

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