Skip to content

Commit

Permalink
Merge branch 'fix/113-boolean-cli-flags'
Browse files Browse the repository at this point in the history
  • Loading branch information
kay-schecker committed Nov 5, 2020
2 parents f16f90c + 90e5e5f commit 66b3094
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 3 additions & 1 deletion apps/generator-cli/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ Initially the file has the following content:
This configuration indicates the following:

- the json file shall be formatted using **2 spaces**
- the jar files shall be downloaded to *./my/custom/storage/dir*
- the generator-cli version 4.3.1 is used

Further it is also possible to configure generators, for example:
Expand All @@ -130,7 +131,8 @@ Further it is also possible to configure generators, for example:
"spaces": 2,
"generator-cli": {
"version": "4.3.1",
"generators": {
"storageDir": "~/my/custom/storage/dir", // optional
"generators": { // optional
"v2.0": { // any name you like (just printed to the console log)
"generatorName": "typescript-angular",
"output": "#{cwd}/output/v2.0/#{ext}/#{name}",
Expand Down
8 changes: 4 additions & 4 deletions apps/generator-cli/src/app/services/generator.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ describe('GeneratorService', () => {
`--rel-dir="def/app"`,
`--rel-path="def/app/pet.yaml"`,
`--ext="yaml"`,
'--some-bool=true',
'--some-bool',
'--some-int=1',
]),
cmd('[baz] def/app/car.json', [
Expand All @@ -152,20 +152,20 @@ describe('GeneratorService', () => {
`--rel-dir="def/app"`,
`--rel-path="def/app/car.json"`,
`--ext="json"`,
'--some-bool=true',
'--some-bool',
'--some-int=1',
]),
]],
['bar.json', [
cmd('[bar] api/cat.yaml', [
`--input-spec="${cwd}/api/cat.yaml"`,
`--output="bar/cat"`,
'--some-bool=false',
'--some-bool',
]),
cmd('[bar] api/bird.json', [
`--input-spec="${cwd}/api/bird.json"`,
`--output="bar/bird"`,
'--some-bool=false',
'--some-bool',
]),
]],
['none.json', []],
Expand Down
5 changes: 3 additions & 2 deletions apps/generator-cli/src/app/services/generator.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,17 @@ export class GeneratorService {
switch (typeof v) {
case 'object':
return `"${Object.entries(v).map(z => z.join('=')).join(',')}"`
case 'boolean':
case 'number':
case 'bigint':
return `${v}`
case 'boolean':
return undefined
default:
return `"${v}"`
}
})()

return `--${key}=${value}`
return value === undefined ? `--${key}` : `--${key}=${value}`
}).join(' ')

const ext = path.extname(absoluteSpecPath)
Expand Down

0 comments on commit 66b3094

Please sign in to comment.