mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-26 23:28:43 +00:00
14 lines
544 B
TypeScript
14 lines
544 B
TypeScript
import { Flag } from "effect/cli"
|
|
|
|
// `--name` and `--name=` parse as `true`, `--name=value` as the value. Like git's `--color[=when]`, the value must be
|
|
// attached with `=`: the next argument is never consumed, so `opencode run -w "fix it"` keeps "fix it" positional.
|
|
export function optionalValue(name: string, metavar: string) {
|
|
return Flag.String(name).pipe(
|
|
Flag.withOptionalValue(""),
|
|
Flag.withMetavar(metavar),
|
|
Flag.map((value): string | true => value || true),
|
|
Flag.optional,
|
|
)
|
|
}
|
|
|
|
export * as CliFlag from "./flag"
|