1
0
CompleteNodeJS/notes-app/app.js
Jason Williams 15a11f8ac9 Video 23
2019-08-11 13:48:11 -06:00

64 lines
1.0 KiB
JavaScript

const chalk = require('chalk');
const yargs = require('yargs');
const notes = require('./notes.js');
// Customize yargs version
yargs.version('1.1.0');
// Create add command
yargs.command({
command: 'add',
describe: 'Add a new note',
builder: {
title: {
describe: 'Note title',
demandOption: true,
type: 'string'
},
body: {
describe: 'Note body',
demandOption: true,
type: 'string'
}
},
handler(argv) {
notes.addNote(argv.title, argv.body);
}
});
// Create remove command
yargs.command({
command: 'remove',
describe: 'Remove a note',
builder: {
title: {
describe: 'Note title',
demandOption: true,
type: 'string'
}
},
handler(argv) {
notes.removeNote(argv.title);
}
});
// Create list command
yargs.command({
command: 'list',
describe: 'List notes',
handler() {
notes.listNotes();
}
});
// Create read command
yargs.command({
command: 'read',
describe: 'Read a note',
handler() {
console.log('Reading a note');
}
});
yargs.parse();