Skip to content

Instantly share code, notes, and snippets.

@ZeroX-DG
Created June 18, 2018 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZeroX-DG/52d9f3346a8d2ad0725c91fcf528e3b2 to your computer and use it in GitHub Desktop.
Save ZeroX-DG/52d9f3346a8d2ad0725c91fcf528e3b2 to your computer and use it in GitHub Desktop.
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