gamelog/bin/cli.js

80 lines
1.6 KiB
JavaScript
Raw Normal View History

2021-12-23 21:52:43 +00:00
const inquirer = require('inquirer');
const { exec } = require('child_process');
2022-02-11 22:08:17 +00:00
const database = 'db/games.rec';
2021-12-23 21:52:43 +00:00
console.log('Create a new gamelog')
const questions = [
{
type: 'input',
name: 'System',
message: 'System (e.g. D&D, Troika!, etc.)',
},
{
type: 'input',
name: 'Module',
message: `What's the name of the module?`,
},
{
type: 'list',
name: 'Role',
message: 'Were you the DM or a player?',
choices: ['DM', 'Player'],
},
{
type: 'input',
name: 'Format',
message: 'Format? (e.g. play by post, roll20, etc)'
},
{
type: 'list',
name: 'Length',
message: 'Length',
choices: ['Campaign', 'Oneshot', 'Adventure']
},
{
type: 'list',
name: 'Status',
message: 'Status',
choices: ['Ongoing', 'Complete', 'Hiatus', 'Dead']
},
{
type: 'input',
name: 'Started',
message: 'Started At (YYYY-MM-DD)',
validate(value) {
const valid = value.match(/\d{4}-\d{2}-\d{2}/);
return valid && true || 'Enter YYYY-MM-DD';
}
},
{
type: 'editor',
name: 'Notes',
message: 'How did it go?'
},
];
inquirer.prompt(questions).then((answers) => {
let cmd = `recins --verbose -t Game `
2023-02-10 03:44:22 +00:00
answers.Updated = answers.Started
2021-12-23 21:52:43 +00:00
for (key in answers) {
cmd += `-f ${key} -v "${answers[key]?.trim() || 'unk'}" `
}
2022-02-11 22:08:17 +00:00
cmd += database
2021-12-23 21:52:43 +00:00
console.log(cmd)
exec(cmd, (error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`);
return;
}
if (stderr) {
console.log(`stderr: ${stderr}`);
return;
}
console.log(`stdout: ${stdout}`);
});
});