Skip to content

Commit 537254a

Browse files
Merge branch 'master' into release/bin/revamp
2 parents fdf7c98 + 4195020 commit 537254a

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/quicktype-core/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"@types/unicode-properties": "^1.3.0",
3737
"@types/urijs": "^1.19.25",
3838
"@types/wordwrap": "^1.0.3",
39+
"command-line-args": "^5.2.1",
3940
"typescript": "~5.8.3"
4041
},
4142
"overrides": {

packages/quicktype-core/src/RendererOptions/types.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
import type { EnumOption, Option } from "./index";
2+
import type { OptionDefinition as CommandLineArgsOptionDefinition } from "command-line-args";
23

34
/**
45
* Primary options show up in the web UI in the "Language" settings tab,
56
* Secondary options in "Other".
67
* CLI is only for cli
78
*/
89
export type OptionKind = "primary" | "secondary" | "cli";
10+
export type OptionType = "string" | "boolean" | "enum";
911

10-
export interface OptionDefinition<Name extends string = string, T = unknown> {
12+
export interface OptionDefinition<Name extends string = string, T = unknown>
13+
extends CommandLineArgsOptionDefinition {
1114
/** Option Name */
1215
name: Name;
13-
/** Option Alias for CLI */
14-
alias?: string;
1516
/** Option Description */
1617
description: string;
1718
/** Category of Option */
18-
optionType: "string" | "boolean" | "enum";
19+
optionType: OptionType;
1920
/** Default Value for Option */
2021
defaultValue?: T;
2122
/** Enum only, map of possible keys and values */

src/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ function makeOptionDefinitions(
456456
typeLabel: "FILE|URL|DIRECTORY",
457457
description: "The file, url, or data directory to type.",
458458
kind: "cli",
459+
defaultOption: true,
459460
},
460461
{
461462
name: "src-urls",
@@ -728,7 +729,13 @@ function parseOptions(
728729
): Partial<CLIOptions> {
729730
let opts: commandLineArgs.CommandLineOptions;
730731
try {
731-
opts = commandLineArgs(definitions, { argv, partial });
732+
opts = commandLineArgs(
733+
definitions.map((def) => ({
734+
...def,
735+
type: def.optionType === "boolean" ? Boolean : String,
736+
})),
737+
{ argv, partial },
738+
);
732739
} catch (e) {
733740
assert(!partial, "Partial option parsing should not have failed");
734741
return messageError("DriverCLIOptionParsingFailed", {

0 commit comments

Comments
 (0)