UNPKG

1.85 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 browser = require('../lib/util/browser');
21var rootCommands = require('../lib/commands/commands');
22var cli = require('../lib/util/cli');
23var execute = cli.execute;
24
25app.version(require('../lib/util/cli').version());
26
27app
28 .command('project <action>', 'project actions');
29
30app
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
39app
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
45app
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
51app.parse(process.argv);
52cli.validate(app);
\No newline at end of file