Skip to content

Instantly share code, notes, and snippets.

@ZeroX-DG
Created June 18, 2018 10:54
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/5add424f57ebb31f1715419bd95faa93 to your computer and use it in GitHub Desktop.
Save ZeroX-DG/5add424f57ebb31f1715419bd95faa93 to your computer and use it in GitHub Desktop.
import {Command, flags} from '@oclif/command'
import chalk from 'chalk'
import todoAPI from '../api/todoAPI'
export default class Add extends Command {
static description = 'Add new todo to list'
static args = [{name: 'todo'}]
static flags = {
done: flags.boolean({ char: 'd' })
}
async run() {
const {args, flags} = this.parse(Add)
const todo = args.todo
if (todo) {
if (flags.done) {
todoAPI.add(todo, true)
} else {
todoAPI.add(todo)
}
this.log(`${chalk.green('[Success]')} Added new todo: ${todo}`)
} else {
this.error(chalk.red('please specify the new todo'))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment