Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/quicktype-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"@types/unicode-properties": "^1.3.0",
"@types/urijs": "^1.19.25",
"@types/wordwrap": "^1.0.3",
"command-line-args": "^5.2.1",
"typescript": "~5.8.3"
},
"overrides": {
Expand Down
9 changes: 5 additions & 4 deletions packages/quicktype-core/src/RendererOptions/types.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import type { EnumOption, Option } from "./index";
import type { OptionDefinition as CommandLineArgsOptionDefinition } from "command-line-args";

/**
* Primary options show up in the web UI in the "Language" settings tab,
* Secondary options in "Other".
* CLI is only for cli
*/
export type OptionKind = "primary" | "secondary" | "cli";
export type OptionType = "string" | "boolean" | "enum";

export interface OptionDefinition<Name extends string = string, T = unknown> {
export interface OptionDefinition<Name extends string = string, T = unknown>
extends CommandLineArgsOptionDefinition {
/** Option Name */
name: Name;
/** Option Alias for CLI */
alias?: string;
/** Option Description */
description: string;
/** Category of Option */
optionType: "string" | "boolean" | "enum";
optionType: OptionType;
/** Default Value for Option */
defaultValue?: T;
/** Enum only, map of possible keys and values */
Expand Down
9 changes: 8 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ function makeOptionDefinitions(
typeLabel: "FILE|URL|DIRECTORY",
description: "The file, url, or data directory to type.",
kind: "cli",
defaultOption: true,
},
{
name: "src-urls",
Expand Down Expand Up @@ -725,7 +726,13 @@ function parseOptions(
): Partial<CLIOptions> {
let opts: commandLineArgs.CommandLineOptions;
try {
opts = commandLineArgs(definitions, { argv, partial });
opts = commandLineArgs(
definitions.map((def) => ({
...def,
type: def.optionType === "boolean" ? Boolean : String,
})),
{ argv, partial },
);
} catch (e) {
assert(!partial, "Partial option parsing should not have failed");
return messageError("DriverCLIOptionParsingFailed", {
Expand Down
Loading