diff --git a/src/commands/checkin.ts b/src/commands/checkin.ts new file mode 100644 index 0000000..ec2ee5b --- /dev/null +++ b/src/commands/checkin.ts @@ -0,0 +1,30 @@ +import {Args, Command, Flags} from '@oclif/core' + +export default class Checkin extends Command { + static description = 'describe the command here' + + static examples = [ + '<%= config.bin %> <%= command.id %>', + ] + + static flags = { + // 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 = { + file: Args.string({description: 'file to read'}), + } + + public async run(): Promise { + const {args, flags} = await this.parse(Checkin) + + const name = flags.name ?? 'world' + this.log(`hello ${name} from src/commands/checkin.ts`) + if (args.file && flags.force) { + this.log(`you input --force and --file: ${args.file}`) + } + } +} diff --git a/src/commands/checkout.ts b/src/commands/checkout.ts new file mode 100644 index 0000000..b9f13ac --- /dev/null +++ b/src/commands/checkout.ts @@ -0,0 +1,30 @@ +import {Args, Command, Flags} from '@oclif/core' + +export default class Checkout extends Command { + static description = 'describe the command here' + + static examples = [ + '<%= config.bin %> <%= command.id %>', + ] + + static flags = { + // 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 = { + file: Args.string({description: 'file to read'}), + } + + public async run(): Promise { + const {args, flags} = await this.parse(Checkout) + + const name = flags.name ?? 'world' + this.log(`hello ${name} from src/commands/checkout.ts`) + if (args.file && flags.force) { + this.log(`you input --force and --file: ${args.file}`) + } + } +} diff --git a/test/commands/checkin.test.ts b/test/commands/checkin.test.ts new file mode 100644 index 0000000..472b202 --- /dev/null +++ b/test/commands/checkin.test.ts @@ -0,0 +1,17 @@ +import {expect, test} from '@oclif/test' + +describe('checkin', () => { + test + .stdout() + .command(['checkin']) + .it('runs hello', ctx => { + expect(ctx.stdout).to.contain('hello world') + }) + + test + .stdout() + .command(['checkin', '--name', 'jeff']) + .it('runs hello --name jeff', ctx => { + expect(ctx.stdout).to.contain('hello jeff') + }) +}) diff --git a/test/commands/checkout.test.ts b/test/commands/checkout.test.ts new file mode 100644 index 0000000..6ff3268 --- /dev/null +++ b/test/commands/checkout.test.ts @@ -0,0 +1,17 @@ +import {expect, test} from '@oclif/test' + +describe('checkout', () => { + test + .stdout() + .command(['checkout']) + .it('runs hello', ctx => { + expect(ctx.stdout).to.contain('hello world') + }) + + test + .stdout() + .command(['checkout', '--name', 'jeff']) + .it('runs hello --name jeff', ctx => { + expect(ctx.stdout).to.contain('hello jeff') + }) +})