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-26 20:56:19 +00:00
|
|
|
exec('gdate -I', (err, stdout, stderr) => {
|
|
|
|
answers.Updated = stdout
|
|
|
|
})
|
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;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|