Skip to content

Instantly share code, notes, and snippets.

@ZeroX-DG
Created June 18, 2018 10:39
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/27d0fdb58851542b5db222b40a9c157d to your computer and use it in GitHub Desktop.
Save ZeroX-DG/27d0fdb58851542b5db222b40a9c157d to your computer and use it in GitHub Desktop.
import {Command} from '@oclif/command'
import chalk from 'chalk'
import todoAPI from '../api/todoAPI'
export default class Remove extends Command {
static description = 'Remove a todo from list'
static args = [{name: 'index'}]
async run() {
const {args} = this.parse(Remove)
const index = args.index
if (index) {
const todo = todoAPI.get(index).todo
todoAPI.remove(index)
this.log(`${chalk.green('[Success]')} Removed todo: ${todo}`)
} else {
this.error(chalk.red('please specify the todo\'s index'))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment