81 lines
1.6 KiB
JavaScript
81 lines
1.6 KiB
JavaScript
const inquirer = require('inquirer');
|
|
const { exec } = require('child_process');
|
|
|
|
const database = 'db/games.rec';
|
|
|
|
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 `
|
|
exec('gdate -I', (err, stdout, stderr) => {
|
|
answers.Updated = stdout
|
|
})
|
|
for (key in answers) {
|
|
cmd += `-f ${key} -v "${answers[key]?.trim() || 'unk'}" `
|
|
}
|
|
cmd += database
|
|
|
|
console.log(cmd)
|
|
|
|
exec(cmd, (error, stdout, stderr) => {
|
|
if (error) {
|
|
console.log(`error: ${error.message}`);
|
|
return;
|
|
}
|
|
if (stderr) {
|
|
console.log(`stderr: ${stderr}`);
|
|
return;
|
|
}
|
|
});
|
|
});
|