1 | #!/usr/bin/env node
|
2 | /****************************************************************************
|
3 | Copyright 2015 Apigee Corporation
|
4 |
|
5 | Licensed under the Apache License, Version 2.0 (the "License");
|
6 | you may not use this file except in compliance with the License.
|
7 | You may obtain a copy of the License at
|
8 |
|
9 | http://www.apache.org/licenses/LICENSE-2.0
|
10 |
|
11 | Unless required by applicable law or agreed to in writing, software
|
12 | distributed under the License is distributed on an "AS IS" BASIS,
|
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 | See the License for the specific language governing permissions and
|
15 | limitations under the License.
|
16 | ****************************************************************************/
|
17 | 'use strict';
|
18 |
|
19 | var app = require('commander');
|
20 | var project = require('../lib/commands/project/project');
|
21 | var cli = require('../lib/util/cli');
|
22 | var execute = cli.execute;
|
23 | var frameworks = Object.keys(project.frameworks).join('|');
|
24 | var assertiontypes = project.assertiontypes.join('|');
|
25 | var testmodules = project.testmodules.join('|');
|
26 |
|
27 | app
|
28 | .command('create [name]')
|
29 | .description('Create a folder containing a Swagger project')
|
30 | .action(execute(project.create));
|
31 |
|
32 | app
|
33 | .command('start [directory]')
|
34 | .description('Start the project in this or the specified directory')
|
35 | .option('-d, --debug [port]', 'start in remote debug mode')
|
36 | .option('-b, --debug-brk [port]', 'start in remote debug mode, wait for debugger connect')
|
37 | .option('-m, --mock', 'start in mock mode')
|
38 | .option('-o, --open', 'open browser as client to the project')
|
39 | .option('-n, --node-args <args>', 'run node with extra arguments (like --node-args \"--harmony\")')
|
40 | .action(execute(project.start));
|
41 |
|
42 | app
|
43 | .command('verify [directory]')
|
44 | .description('Verify that the project is correct (swagger, config, etc)')
|
45 | .option('-j, --json', 'output as JSON')
|
46 | .action(execute(project.verify));
|
47 |
|
48 | app
|
49 | .command('edit [directory]')
|
50 | .description('open Swagger editor for this project or the specified project directory')
|
51 | .option('-s, --silent', 'do not open the browser')
|
52 | .option('--host <host>', 'the hostname the editor is served from')
|
53 | .option('-p, --port <port>', 'the port the editor is served from')
|
54 | .action(execute(project.edit));
|
55 |
|
56 | app
|
57 | .command('open [directory]')
|
58 | .description('open browser as client to the project')
|
59 | .action(execute(project.open));
|
60 |
|
61 | app
|
62 | .command('test [directory_or_file]')
|
63 | .description('Run project tests')
|
64 | .option('-d, --debug [port]', 'start in remote debug mode')
|
65 | .option('-b, --debug-brk [port]', 'start in remote debug mode, wait for debugger connect')
|
66 | .option('-m, --mock', 'run in mock mode')
|
67 | .action(execute(project.test));
|
68 |
|
69 | app
|
70 | .command('generate-test [directory]')
|
71 | .description('Generate the test template')
|
72 | .option('-p, --path-name [path]', 'a specific path of the api, also supports regular expression')
|
73 | .option('-f, --test-module <module>', 'one of: ' + testmodules)
|
74 | .option('-t, --assertion-format <type>', 'one of: ' + assertiontypes)
|
75 | .option('-o, --force', 'allow overwriting of all existing test files matching those generated')
|
76 | .option('-l, --load-test [path]', 'generate load-tests for specified operations')
|
77 | .action(execute(project.generateTest));
|
78 |
|
79 | //app
|
80 | // .command('generate-secret [directory]')
|
81 | // .description('Generate secret key for hotp security (only allowing direct access via syndicator)')
|
82 | // .action(execute(project.generateSecret));
|
83 |
|
84 | app
|
85 | .command('generate-routes [directory]')
|
86 | .description('Generate routes using the swagger doc in the project')
|
87 | .action(execute(project.generateRoutes));
|
88 |
|
89 | app.parse(process.argv);
|
90 | cli.validate(app);
|