@@ -5,18 +5,19 @@ import { Options } from './options.js';
5
5
import fs from 'fs' ;
6
6
import { kebabCase } from 'lodash' ;
7
7
8
- const Mnemonics : { [ key : string ] : string } = { 'input' : 'i' , 'output' : 'o' } ;
9
- const DefaultConfig = 'ng-openapi-gen.json' ;
8
+ const MNEMONICS : { [ key : string ] : string } = { 'input' : 'i' , 'output' : 'o' } ;
9
+ const DEFAULT = 'ng-openapi-gen.json' ;
10
10
11
11
function createParser ( ) {
12
12
const argParser = new ArgumentParser ( {
13
+ // eslint-disable-next-line @typescript-eslint/naming-convention
13
14
add_help : true ,
14
15
description : `
15
16
Generator for API clients described with OpenAPI 3.0 specification for
16
17
Angular 6+ projects. Requires a configuration file, which defaults to
17
- ${ DefaultConfig } in the current directory. The file can also be
18
+ ${ DEFAULT } in the current directory. The file can also be
18
19
specified using '--config <file>' or '-c <file>'.
19
- All settings in the configuration file can be overridding by setting the
20
+ All settings in the configuration file can be overriding by setting the
20
21
corresponding argument in the command-line. For example, to specify a
21
22
custom suffix for service classes via command-line, pass the command-line
22
23
argument '--serviceSuffix Suffix'. Kebab-case is also accepted, so, the same
@@ -38,9 +39,9 @@ a configuration file is only required if no --input argument is set.`.trim()
38
39
{
39
40
help : `
40
41
The configuration file to be used. If not specified, assumes that
41
- ${ DefaultConfig } in the current directory`. trim ( ) ,
42
+ ${ DEFAULT } in the current directory`. trim ( ) ,
42
43
dest : 'config' ,
43
- default : `./${ DefaultConfig } `
44
+ default : `./${ DEFAULT } `
44
45
}
45
46
) ;
46
47
const props = schema . properties ;
@@ -51,7 +52,7 @@ ${DefaultConfig} in the current directory`.trim(),
51
52
const kebab = kebabCase ( key ) ;
52
53
const desc = ( props as any ) [ key ] ;
53
54
const names = [ ] ;
54
- const mnemonic = Mnemonics [ key ] ;
55
+ const mnemonic = MNEMONICS [ key ] ;
55
56
if ( mnemonic ) {
56
57
names . push ( '-' + mnemonic ) ;
57
58
}
@@ -77,9 +78,9 @@ export function parseOptions(sysArgs?: string[]): Options {
77
78
if ( args . config ) {
78
79
if ( fs . existsSync ( args . config ) ) {
79
80
options = JSON . parse ( fs . readFileSync ( args . config , { encoding : 'utf-8' } ) ) ;
80
- } else if ( args . config === `./${ DefaultConfig } ` ) {
81
+ } else if ( args . config === `./${ DEFAULT } ` ) {
81
82
if ( ( args . input || '' ) . length === 0 ) {
82
- throw new Error ( `No input is given, and the file ${ DefaultConfig } doesn't exist.
83
+ throw new Error ( `No input is given, and the file ${ DEFAULT } doesn't exist.
83
84
For help, run ng-openapi-gen --help` ) ;
84
85
}
85
86
} else {
@@ -111,7 +112,7 @@ For help, run ng-openapi-gen --help`);
111
112
options [ key ] = value ;
112
113
}
113
114
}
114
- if ( options . input == undefined || options . input === '' ) {
115
+ if ( options . input === undefined || options . input === '' ) {
115
116
throw new Error ( 'No input (OpenAPI specification) defined' ) ;
116
117
}
117
118
return options ;
0 commit comments