UNPKG

3.75 kBPlain TextView Raw
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
19var app = require('commander');
20var project = require('../lib/commands/project/project');
21var cli = require('../lib/util/cli');
22var execute = cli.execute;
23var frameworks = Object.keys(project.frameworks).join('|');
24var assertiontypes = project.assertiontypes.join('|');
25var testmodules = project.testmodules.join('|');
26
27app
28 .command('create [name]')
29 .description('Create a folder containing a Swagger project')
30 .action(execute(project.create));
31
32app
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
42app
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
48app
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
56app
57 .command('open [directory]')
58 .description('open browser as client to the project')
59 .action(execute(project.open));
60
61app
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
69app
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
84app
85 .command('generate-routes [directory]')
86 .description('Generate routes using the swagger doc in the project')
87 .action(execute(project.generateRoutes));
88
89app.parse(process.argv);
90cli.validate(app);