Skip to content

Instantly share code, notes, and snippets.

@kenanchristian
Last active September 21, 2020 06:39
Show Gist options
  • Save kenanchristian/293d4b38171cf9e13aa1b9c6bd21068e to your computer and use it in GitHub Desktop.
Save kenanchristian/293d4b38171cf9e13aa1b9c6bd21068e to your computer and use it in GitHub Desktop.
[[Typescript CLI] Starting Code] Code generated by OCLIF framework #oclif #cli #writing
import {Command, flags} from '@oclif/command'
export default class Hello extends Command {
static description = 'describe the command here'
static examples = [
`$ pizza hello
hello world from ./src/hello.ts!
`,
]
static flags = {
help: flags.help({char: 'h'}),
// flag with a value (-n, --name=VALUE)
name: flags.string({char: 'n', description: 'name to print'}),
// flag with no value (-f, --force)
force: flags.boolean({char: 'f'}),
}
static args = [{name: 'file'}]
async run() {
const {args, flags} = this.parse(Hello)
const name = flags.name ?? 'world'
this.log(`hello ${name} from ./src/commands/hello.ts`)
if (args.file && flags.force) {
this.log(`you input --force and --file: ${args.file}`)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment