Created
June 18, 2018 10:39
-
-
Save ZeroX-DG/27d0fdb58851542b5db222b40a9c157d 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 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