UNPKG

1.23 kBJavaScriptView Raw
1#!/usr/bin/env node
2const cli = require('yargs')
3const debug = (process.env.DEBUG === 'true')
4const version = require('./package.json').version
5
6const runCommand = require('./lib/commands/run')
7const inspectCommand = require('./lib/commands/inspect')
8const resetCommand = require('./lib/commands/reset')
9const routeCommand = require('./lib/commands/route')
10
11console.log(`Noop CLI v${version}`)
12
13cli.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
20cli.command('inspect', 'inspect noop app', inspectCommand)
21
22cli.command('reset [resourceName]', 'reset resource state', (yargs) => {
23 yargs.positional('resourceName', {
24 describe: 'name of resource to reset state'
25 })
26}, resetCommand)
27
28cli.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
37const argv = cli.argv // no idea wtf reading `argv` props does to make it work
38if (debug) console.log(argv)