Created
June 18, 2018 10:30
-
-
Save ZeroX-DG/52d9f3346a8d2ad0725c91fcf528e3b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Command} from '@oclif/command' | |
import todoAPI from '../api/todoAPI' | |
import chalk from 'chalk' | |
const Table = require('cli-table') | |
export default class List extends Command { | |
static description = 'Print out all todos' | |
async run() { | |
const table = new Table({ | |
head: [ | |
chalk.blueBright('index'), | |
chalk.blueBright('todo'), | |
chalk.blueBright('status') | |
] | |
}); | |
const todos = todoAPI.list() | |
for (let i = 0; i < todos.length; i++) { | |
const todo = todos[i] | |
const status = todo.done ? chalk.green('done') : chalk.red('not done') | |
table.push([ i, todo.todo, status ]) | |
} | |
this.log(table.toString()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment