Video 23
This commit is contained in:
parent
63e639fab3
commit
15a11f8ac9
@ -47,7 +47,7 @@ yargs.command({
|
|||||||
command: 'list',
|
command: 'list',
|
||||||
describe: 'List notes',
|
describe: 'List notes',
|
||||||
handler() {
|
handler() {
|
||||||
console.log('Listing out all notes');
|
notes.listNotes();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -34,6 +34,15 @@ const removeNote = (title) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const listNotes = () => {
|
||||||
|
const notes = loadNotes();
|
||||||
|
|
||||||
|
console.log(chalk.cyan.underline('Your notes:'));
|
||||||
|
notes.forEach((note) => {
|
||||||
|
console.log(note.title);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const saveNotes = (notes) => {
|
const saveNotes = (notes) => {
|
||||||
const dataJSON = JSON.stringify(notes);
|
const dataJSON = JSON.stringify(notes);
|
||||||
fs.writeFileSync('notes.json', dataJSON);
|
fs.writeFileSync('notes.json', dataJSON);
|
||||||
@ -52,5 +61,6 @@ const loadNotes = () => {
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
getNotes: getNotes,
|
getNotes: getNotes,
|
||||||
addNote: addNote,
|
addNote: addNote,
|
||||||
removeNote: removeNote
|
removeNote: removeNote,
|
||||||
|
listNotes: listNotes
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
[{"title":"List","body":"Sweater, Pants"}]
|
[{"title":"List","body":"Sweater, Pants"},{"title":"Course Ideas","body":""}]
|
Loading…
Reference in New Issue
Block a user