Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const fs = require('fs');
- const os = require('os');
- const _ = require('lodash');
- const yargs = require('yargs');
- const notes = require('./notes.js')
- const argv = yargs.argv;
- var command = argv._[0];
- console.log(' Your Command: ', command);
- console.log(' Your processes is: ',process.argv);
- console.log(' Your Yargs is: ', argv);
- if (command === 'add') {
- var note = notes.addNote(argv.title, argv.body);
- if (note) {
- console.log(" You write the new object in notes");
- notes.logNote;
- } else {
- console.log(" You write an exist objects in node");
- console.log(' -- which is');
- // here I can't call note.title = undifiend same with note.body = undifined
- // I want to log the title if was exists
- // console.log(` Title: ${note.title}`);
- // console.log(` body: ${note.body}`);
- };
- } else if (command === 'list') {
- var allNotes = notes.getAll();
- console.log(` listing all list ${allNotes.length} note(s)`);
- allNotes.forEach((note) => notes.logNote(note));
- } else if(command === 'read') {
- var note = notes.getNote(argv.title);
- if (note) {
- console.log(" You fetch the note and read it");
- notes.logNote(note);
- } else {
- console.log(" Your note was not exist");
- }
- console.log(' fetch or read from note called done');
- } else if (command === 'remove') {
- var noteRemoved = notes.getRemove(argv.title);
- var message = noteRemoved ? " The note you try to remove was removed" : " The note you are looking not found"
- console.log(message);
- console.log(' Hey you just remove a note with NodeJS command');
- } else {
- console.log(' Your command not in my list command that i made');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement