Advertisement
Guest User

Untitled

a guest
Apr 24th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. const fs = require('fs');
  2. const os = require('os');
  3. const _ = require('lodash');
  4. const yargs = require('yargs');
  5.  
  6.  
  7. const notes = require('./notes.js')
  8. const argv = yargs.argv;
  9.  
  10. var command = argv._[0];
  11. console.log(' Your Command: ', command);
  12. console.log(' Your processes is: ',process.argv);
  13. console.log(' Your Yargs is: ', argv);
  14.  
  15. if (command === 'add') {
  16. var note = notes.addNote(argv.title, argv.body);
  17. if (note) {
  18. console.log(" You write the new object in notes");
  19. notes.logNote;
  20. } else {
  21. console.log(" You write an exist objects in node");
  22. console.log(' -- which is');
  23. // here I can't call note.title = undifiend same with note.body = undifined
  24. // I want to log the title if was exists
  25. // console.log(` Title: ${note.title}`);
  26. // console.log(` body: ${note.body}`);
  27. };
  28. } else if (command === 'list') {
  29. var allNotes = notes.getAll();
  30. console.log(` listing all list ${allNotes.length} note(s)`);
  31. allNotes.forEach((note) => notes.logNote(note));
  32. } else if(command === 'read') {
  33. var note = notes.getNote(argv.title);
  34. if (note) {
  35. console.log(" You fetch the note and read it");
  36. notes.logNote(note);
  37. } else {
  38. console.log(" Your note was not exist");
  39. }
  40. console.log(' fetch or read from note called done');
  41. } else if (command === 'remove') {
  42. var noteRemoved = notes.getRemove(argv.title);
  43. var message = noteRemoved ? " The note you try to remove was removed" : " The note you are looking not found"
  44. console.log(message);
  45. console.log(' Hey you just remove a note with NodeJS command');
  46. } else {
  47. console.log(' Your command not in my list command that i made');
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement