Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow equals sign in aliased parameter values. #2755

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion packages/cli/src/internal/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,7 @@ const parseInternal = (
const extractKeyValue = (
value: string
): Effect.Effect<[string, string], ValidationError.ValidationError> => {
const split = value.trim().split("=")
const split = value.trim().split("=", 1)
IMax153 marked this conversation as resolved.
Show resolved Hide resolved
if (Arr.isNonEmptyReadonlyArray(split) && split.length === 2 && split[1] !== "") {
return Effect.succeed(split as unknown as [string, string])
}
Expand Down
7 changes: 7 additions & 0 deletions packages/cli/test/Options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,13 @@ describe("Options", () => {
expect(result).toEqual([["--verbose"], HashMap.make(["key1", "v1"], ["key2", "v2"])])
}).pipe(runEffect))

it("keyValueMap - validates key/values with equals in alias value", () =>
Effect.gen(function*(_) {
const args = Array.make("-d", "key1=v1", "key2=v2=vv", "--verbose")
const result = yield* _(process(defs, args, CliConfig.defaultConfig))
expect(result).toEqual([["--verbose"], HashMap.make(["key1", "v1"], ["key2", "v2=vv"])])
}).pipe(runEffect))

it("keyValueMap - validate should keep non-key-value parameters that follow the key-value pairs (each preceded by alias -d)", () =>
Effect.gen(function*(_) {
const args = Array.make(
Expand Down
Loading