1 | #!/usr/bin/env node
|
2 | const cli = require('yargs')
|
3 | const debug = (process.env.DEBUG === 'true')
|
4 | const version = require('./package.json').version
|
5 |
|
6 | const runCommand = require('./lib/commands/run')
|
7 | const inspectCommand = require('./lib/commands/inspect')
|
8 | const resetCommand = require('./lib/commands/reset')
|
9 | const routeCommand = require('./lib/commands/route')
|
10 |
|
11 | console.log(`Noop CLI v${version}`)
|
12 |
|
13 | cli.command('run [port]', 'run local dev server', (yargs) => {
|
14 | yargs.positional('port', {
|
15 | describe: 'port to bind local dev server',
|
16 | default: 1234
|
17 | })
|
18 | }, runCommand)
|
19 |
|
20 | cli.command('inspect', 'inspect noop app', inspectCommand)
|
21 |
|
22 | cli.command('reset [resourceName]', 'reset resource state', (yargs) => {
|
23 | yargs.positional('resourceName', {
|
24 | describe: 'name of resource to reset state'
|
25 | })
|
26 | }, resetCommand)
|
27 |
|
28 | cli.command('route [method] [path]', 'evaluate routing of a specific request', (yargs) => {
|
29 | yargs.positional('method', {
|
30 | describe: 'HTTP method for evaluation (GET, PUT, POST, DELETE)'
|
31 | }),
|
32 | yargs.positional('path', {
|
33 | describe: 'HTTP path for evaluation like /foo/bar'
|
34 | })
|
35 | }, routeCommand)
|
36 |
|
37 | const argv = cli.argv
|
38 | if (debug) console.log(argv)
|