Skip to content

Commit

Permalink
bin: replace .option with .command
Browse files Browse the repository at this point in the history
fixes: pkgjs#7
  • Loading branch information
AshCripps authored and AshCripps committed Jul 30, 2020
1 parent b24a3d5 commit 734ab3d
Showing 1 changed file with 28 additions and 18 deletions.
46 changes: 28 additions & 18 deletions bin/wiby.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,34 @@
require('dotenv').config()
const test = require('../lib/test')
const result = require('../lib/result')
const yargs = require('yargs')

const args = require('yargs')
.option('test', {
alias: 't',
describe: 'Test your dependents'
})
.option('result', {
alias: 'r',
describe: 'Get the result of your tests'
})
yargs
.command(
'test',
'Test your dependents',
(yargs) => {
yargs
.option('dependent', {
desc: 'URL of a dependent',
demandOption: true,
type: 'string'
})
},
(argv) => {
test(argv.dependent)
}
)
.command(
'result',
'Fetch the results of your tests',
() => {},
() => {
result()
}
)
.help()
.strict()
.argv

if (args.test) {
test(args.test)
}

if (args.result) {
result()
}

// Usage: wiby --test URL
// Usage: wiby test --dependent=URL

0 comments on commit 734ab3d

Please sign in to comment.