1
0
CompleteNodeJS/notes-app/app.js
Jason Williams 6528d7204a Section 20
2019-08-11 12:15:16 -06:00

64 lines
1.1 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: function(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: function(argv) {
notes.removeNote(argv.title);
}
});
// Create list command
yargs.command({
command: 'list',
describe: 'List notes',
handler: function() {
console.log('Listing out all notes');
}
});
// Create read command
yargs.command({
command: 'read',
describe: 'Read a note',
handler: function() {
console.log('Reading a note');
}
});
yargs.parse();