Initial commit
This commit is contained in:
44
skills/oclif-patterns/templates/command-basic.ts
Normal file
44
skills/oclif-patterns/templates/command-basic.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { Command, Flags } from '@oclif/core'
|
||||
|
||||
export default class {{COMMAND_NAME}} extends Command {
|
||||
static description = '{{DESCRIPTION}}'
|
||||
|
||||
static examples = [
|
||||
'<%= config.bin %> <%= command.id %> --name World',
|
||||
'<%= config.bin %> <%= command.id %> --name "John Doe" --verbose',
|
||||
]
|
||||
|
||||
static flags = {
|
||||
name: Flags.string({
|
||||
char: 'n',
|
||||
description: 'Name to use',
|
||||
required: true,
|
||||
}),
|
||||
verbose: Flags.boolean({
|
||||
char: 'v',
|
||||
description: 'Show verbose output',
|
||||
default: false,
|
||||
}),
|
||||
force: Flags.boolean({
|
||||
char: 'f',
|
||||
description: 'Force operation',
|
||||
default: false,
|
||||
}),
|
||||
}
|
||||
|
||||
static args = {}
|
||||
|
||||
async run(): Promise<void> {
|
||||
const { flags } = await this.parse({{COMMAND_NAME}})
|
||||
|
||||
if (flags.verbose) {
|
||||
this.log('Verbose mode enabled')
|
||||
}
|
||||
|
||||
this.log(`Hello, ${flags.name}!`)
|
||||
|
||||
if (flags.force) {
|
||||
this.log('Force mode: proceeding without confirmation')
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user