ditto/tribes-cli/cli.ts
2024-09-30 02:38:32 +05:30

32 lines
881 B
TypeScript

import { tribe } from './tribe/mod.ts';
import { remote } from './remote/mod.ts';
import { Command, defaultIdentityFile } from './utils/mod.ts';
async function main() {
const tribes = new Command('tribes-cli', 'Create and manage Ditto Tribes servers.')
.subcommand(tribe)
.subcommand(remote)
.option('-i --identity-file', {
description: 'The ssh identity file to use. You will be prompted if this is not supplied.',
});
const { parsed } = tribes.parse(Deno.args);
parsed['identity-file'] = await defaultIdentityFile(parsed['identity-file'] as string);
const [s, v] = parsed._.slice(1);
let cmd = tribes;
if (s) cmd = tribes.getSubcommand(s);
if (v) cmd = cmd.getSubcommand(v);
await cmd.doAction(parsed);
}
if (import.meta.main) {
try {
await main();
} catch (e) {
console.error('ERROR:', e.message);
Deno.exit(1);
}
}