Files
blitzkit/src/core/process/args.ts
T

21 lines
491 B
TypeScript
Raw Normal View History

2023-04-28 13:42:42 +00:00
import { argv } from 'process';
type ArgumentName = 'discord-token' | 'wargaming-application-id';
export const args: Record<ArgumentName, string> = {
'discord-token': '',
'wargaming-application-id': '',
};
argv.forEach((arg) => {
if (arg.includes('=')) {
const [name, value] = arg.split('=');
args[name as ArgumentName] = value;
}
});
Object.keys(args).forEach((arg) => {
if (args[arg as ArgumentName] === '') {
throw new Error(`Missing argument: ${arg}`);
}
});