-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotes.js
50 lines (43 loc) · 1.06 KB
/
notes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env node
const notesManager = require('./notesManager.js');
var program = require('commander');
program
.version('1.1.1')
.usage('<note-name>')
.action(function(noteName){
console.log('[Display] : "%s"', noteName);
notesManager.show(noteName);
});
program
.command('list')
.alias('l')
.description('Show available notes')
.action(function(){
console.log('[list] all notes :');
notesManager.list();
});
program
.command('add <note-name>')
.alias('a')
.description('add new note or edit existing note')
.action(function(noteName){
console.log('[Add] : "%s"', noteName);
notesManager.add(noteName);
});
program
.command('delete <note-name>')
.alias('d')
.description('delete note')
.action(function(noteName){
console.log('[delete] :', noteName);
notesManager.delete(noteName);
});
program.parse(process.argv);
if (!program.args.length){
console.log([
' Simple command line notes taking app with nodejs ',
' Repository: https://github.com/Med-Salem-Gzizou/notes-cli',
'',
' For help run: $ notes --help'
].join('\n'));
}