Created
June 18, 2018 10:10
-
-
Save ZeroX-DG/61fbf23a61f6cdcfe3f6564467a3a864 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 Add extends Command { | |
static description = 'Add new todo to list' | |
static args = [{name: 'todo'}] | |
async run() { | |
const {args} = this.parse(Add) | |
const todo = args.todo | |
if (todo) { | |
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