This commit is contained in:
Morten Olsen
2024-01-12 12:43:51 +01:00
commit 6d8e5bf955
109 changed files with 9246 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
import { Command } from 'commander';
import { createClient } from '../../client/client.js';
import { step } from '../../utils/step.js';
const list = new Command('list');
const toInt = (value?: string) => {
if (!value) {
return undefined;
}
return parseInt(value, 10);
};
list
.alias('ls')
.description('List logs')
.option('-o, --offset <offset>', 'Offset')
.option('-a, --limit <limit>', 'Limit', '1000')
.action(async () => {
const { offset, limit } = list.opts();
const client = await step('Connecting to server', async () => {
return createClient();
});
const secrets = await step('Getting secrets', async () => {
return await client.secrets.find.query({
offset: toInt(offset),
limit: toInt(limit),
});
});
console.table(secrets);
});
export { list };

View File

@@ -0,0 +1,21 @@
import { Command } from 'commander';
import { createClient } from '../../client/client.js';
import { step } from '../../utils/step.js';
const remove = new Command('remove');
remove
.alias('rm')
.argument('<id>')
.action(async (id) => {
const client = await step('Connecting to server', async () => {
return createClient();
});
await step('Removing', async () => {
await client.secrets.remove.mutate({
id,
});
});
});
export { remove };

View File

@@ -0,0 +1,22 @@
import { Command } from 'commander';
import { createClient } from '../../client/client.js';
import { step } from '../../utils/step.js';
const set = new Command('set');
set
.argument('<id>')
.argument('[value]')
.action(async (id, value) => {
const client = await step('Connecting to server', async () => {
return createClient();
});
await step('Setting secret', async () => {
await client.secrets.set.mutate({
id,
value,
});
});
});
export { set };

View File

@@ -0,0 +1,11 @@
import { Command } from 'commander';
import { list } from './secrets.list.js';
import { set } from './secrets.set.js';
import { remove } from './secrets.remove.js';
const secrets = new Command('secrets');
secrets.addCommand(list);
secrets.addCommand(set);
secrets.addCommand(remove);
export { secrets };