Skip to content

Commit

Permalink
feat: add flags and args
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Sep 21, 2023
1 parent 0252c8f commit ca4f019
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions src/commands/esm2.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,36 @@
import {Command} from '@oclif/core'
import {Args, Command, Flags, Interfaces} from '@oclif/core'

type Result = {
args: Interfaces.InferredArgs<typeof ESM2.args>
flags: Interfaces.InferredFlags<typeof ESM2.flags>
}

export default class ESM2 extends Command {
async run(): Promise<void> {
static flags = {
optionalString: Flags.string(),
defaultString: Flags.string({
default: 'simple string default',
}),
defaultFnString: Flags.string({
default: async () => Promise.resolve('async fn default'),
}),
}

static args = {
optionalArg: Args.string(),
defaultArg: Args.string({
default: 'simple string default',
}),
defaultFnArg: Args.string({
default: async () => Promise.resolve('async fn default'),
}),
}

static enableJsonFlag = true

async run(): Promise<Result> {
const {args, flags} = await this.parse(ESM2)
this.log(`hello I am an ESM plugin from ${this.config.root}!`)
return {args, flags}
}
}

0 comments on commit ca4f019

Please sign in to comment.