diff --git a/packages/core/src/parameter/scanner.ts b/packages/core/src/parameter/scanner.ts index daafe25..02fdd86 100644 --- a/packages/core/src/parameter/scanner.ts +++ b/packages/core/src/parameter/scanner.ts @@ -439,7 +439,7 @@ function findFlagsByArgument( return []; } -const FLAG_NAME_VALUE_PATTERN = /^--([a-z][a-z-]+)=(.+)$/i; +const FLAG_NAME_VALUE_PATTERN = /^--([a-z][a-z-.\d_]+)=(.+)$/i; const ALIAS_VALUE_PATTERN = /^-([a-z])=(.+)$/i; /** diff --git a/packages/core/tests/baselines/reference/parameter/flag/formatting.txt b/packages/core/tests/baselines/reference/parameter/flag/formatting.txt index 8fdbad7..9887df5 100644 --- a/packages/core/tests/baselines/reference/parameter/flag/formatting.txt +++ b/packages/core/tests/baselines/reference/parameter/flag/formatting.txt @@ -44,6 +44,14 @@ :::: formatDocumentationForFlagParameters / no flags -h --help Print help information and exit  -- All subsequent inputs should be interpreted as arguments +:::: formatDocumentationForFlagParameters / parsed / flag with nonstandard character + --a.b.c_10 required parsed flag +-h --help Print help information and exit + -- All subsequent inputs should be interpreted as arguments +:::: formatDocumentationForFlagParameters / parsed / multipart flag + --multi.part required parsed flag +-h --help Print help information and exit + -- All subsequent inputs should be interpreted as arguments :::: formatDocumentationForFlagParameters / parsed / multiple parsed flags  --requiredParsed required parsed flag  --requiredParsedWithLongerName required parsed flag with longer name diff --git a/packages/core/tests/parameter/flag/formatting.spec.ts b/packages/core/tests/parameter/flag/formatting.spec.ts index 3865c3a..8a79914 100644 --- a/packages/core/tests/parameter/flag/formatting.spec.ts +++ b/packages/core/tests/parameter/flag/formatting.spec.ts @@ -728,5 +728,55 @@ describe("formatDocumentationForFlagParameters", function () { // THEN compareToBaseline(this, StringArrayBaselineFormat, lines); }); + + it("multipart flag", function () { + // GIVEN + type Positional = []; + type Flags = { + readonly "multi.part": string; + }; + + const parameters: TypedCommandParameters = { + flags: { + "multi.part": { + kind: "parsed", + parse: String, + brief: "required parsed flag", + }, + }, + positional: { kind: "tuple", parameters: [] }, + }; + + // WHEN + const lines = formatDocumentationForFlagParameters(parameters.flags, parameters.aliases ?? {}, defaultArgs); + + // THEN + compareToBaseline(this, StringArrayBaselineFormat, lines); + }); + + it("flag with nonstandard character", function () { + // GIVEN + type Positional = []; + type Flags = { + readonly "a.b.c_10": string; + }; + + const parameters: TypedCommandParameters = { + flags: { + "a.b.c_10": { + kind: "parsed", + parse: String, + brief: "required parsed flag", + }, + }, + positional: { kind: "tuple", parameters: [] }, + }; + + // WHEN + const lines = formatDocumentationForFlagParameters(parameters.flags, parameters.aliases ?? {}, defaultArgs); + + // THEN + compareToBaseline(this, StringArrayBaselineFormat, lines); + }); }); });