Skip to content

Instantly share code, notes, and snippets.

@kenanchristian
Last active June 24, 2020 18:11
Show Gist options
  • Save kenanchristian/bdb23988b46c888147b61c5068587147 to your computer and use it in GitHub Desktop.
Save kenanchristian/bdb23988b46c888147b61c5068587147 to your computer and use it in GitHub Desktop.
import {Command, flags} from '@oclif/command'
export default class Create extends Command {
static description = 'Create a new Pizza'
static examples = [
`$ pizza create
Your pizza is ready!
`,
]
static flags = {
help: flags.help({char: 'h'}),
crust: flags.string({char: 'c', description: 'Type of Crust (Thin/Thick)'}),
toppings: flags.string({char: 't', description: 'Toppings to add', options: ['pepperoni', 'mushroom', 'bacon', 'pineapple'], multiple: true}),
extraSauce: flags.boolean({char: 'x', description: 'Do you want extra sauce?'}),
}
static args = [
{
name: 'count',
required: false,
description: 'How many pizza you want to create',
parse: (input: string) => parseInt(input, 10) || 1,
default: 1,
},
]
async run() {
const {args, flags} = this.parse(Create)
this.log(JSON.stringify(args))
this.log(JSON.stringify(flags))
this.log('Your pizza is ready!')
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment