2023-04-28 13:42:42 +00:00
|
|
|
import { argv } from 'process';
|
2023-06-06 16:50:33 +00:00
|
|
|
import errorWithCause from './errorWithCause.js';
|
2023-04-28 13:42:42 +00:00
|
|
|
|
|
|
|
|
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] === '') {
|
2023-06-06 16:50:33 +00:00
|
|
|
throw errorWithCause(
|
|
|
|
|
`Missing argument: ${arg}`,
|
|
|
|
|
'Missing required auth key.',
|
|
|
|
|
);
|
2023-04-28 13:42:42 +00:00
|
|
|
}
|
|
|
|
|
});
|