Generate placeholder checkin and checkout commands
This commit is contained in:
parent
3a8b0d0430
commit
2a53b55801
4 changed files with 94 additions and 0 deletions
30
src/commands/checkin.ts
Normal file
30
src/commands/checkin.ts
Normal file
|
@ -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<void> {
|
||||
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}`)
|
||||
}
|
||||
}
|
||||
}
|
30
src/commands/checkout.ts
Normal file
30
src/commands/checkout.ts
Normal file
|
@ -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<void> {
|
||||
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}`)
|
||||
}
|
||||
}
|
||||
}
|
17
test/commands/checkin.test.ts
Normal file
17
test/commands/checkin.test.ts
Normal file
|
@ -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')
|
||||
})
|
||||
})
|
17
test/commands/checkout.test.ts
Normal file
17
test/commands/checkout.test.ts
Normal file
|
@ -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')
|
||||
})
|
||||
})
|
Loading…
Reference in a new issue