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 browser = require('../lib/util/browser');
|
21 | var rootCommands = require('../lib/commands/commands');
|
22 | var cli = require('../lib/util/cli');
|
23 | var execute = cli.execute;
|
24 |
|
25 | app.version(require('../lib/util/cli').version());
|
26 |
|
27 | app
|
28 | .command('project <action>', 'project actions');
|
29 |
|
30 | app
|
31 | .command('docs')
|
32 | .description('open Swagger documentation')
|
33 | .action(function() {
|
34 | browser.open('https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md', function() {
|
35 | process.exit(0);
|
36 | });
|
37 | });
|
38 |
|
39 | app
|
40 | .command('validate [swaggerFile]')
|
41 | .description('validate a Swagger document (supports unix piping)')
|
42 | .option('-j, --json', 'output as JSON')
|
43 | .action(execute(rootCommands.validate));
|
44 |
|
45 | app
|
46 | .command('convert <swaggerFile> [apiDeclarations...]')
|
47 | .description('Converts Swagger 1.2 documents to a Swagger 2.0 document')
|
48 | .option('-o, --output-file <fileName>', 'specify an output-file to write to')
|
49 | .action(execute(rootCommands.convert));
|
50 |
|
51 | app.parse(process.argv);
|
52 | cli.validate(app); |
\ | No newline at end of file |