Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaLeon committed May 10, 2018
0 parents commit 4689e88
Show file tree
Hide file tree
Showing 8 changed files with 516 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Console To-Do App

This is a exercise of node course

Remember install node pakages with follow command:

```
npm install
```
32 changes: 32 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//const argv = require('yargs').argv;
const argv = require('./config/yargs').argv;

const toDo = require('./to-do/to-do');

let command = argv._[0];

switch (command) {
case 'create':
let work = toDo.create(argv.d);
console.log(work);
break;
case 'read':
let toDoList = toDo.getList();

console.log('====To-Do List===='.green);
for (let work of toDoList) {
console.log(work.description);
console.log('status: ', work.complete);
}
console.log('=================='.green);
break;
case 'update':
let updated = toDo.update(argv.description, argv.complete);
console.log(updated);
break;
case 'delete':
let deleted = toDo.delete(argv.description);
console.log(deleted);
default:
console.log('Command not found');
}
28 changes: 28 additions & 0 deletions config/yargs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const description = {
demand: true,
alias: 'd',
desc: 'description of to do work'
}

const complete = {
alias: 'c',
default: true
}

const argv = require('yargs')
.command('create', 'create a to do work', {
description
})
.command('update', 'update status of a to do work', {
description,
complete
})
.command('delete', 'delete a to do work', {
description
})
.help()
.argv;

module.exports = {
argv
}
1 change: 1 addition & 0 deletions db/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"description":"play futbol","complete":"true"},{"description":"learn node","complete":false}]
Loading

0 comments on commit 4689e88

Please sign in to comment.