Effect CommunityEC
Effect Community2y ago
7 replies
whatplan

Issue with `Options.repeated` and option alias

Options.repeated does not seem to work when using an option's alias

import { Console, Effect } from "effect";
import { BunContext, Runtime } from "@effect/platform-bun";
import { Command, Options } from "@effect/cli";
 
const testOption = Options.text("test").pipe(
  Options.withAlias("T"),
  Options.repeated
);
 
const run = Command.make("test", { testOption }, ({ testOption }) =>
  Console.log({
    testOption,
  })
).pipe(
  Command.run({
    name: "Test",
    version: "1.0.0",
  })
);
 
const main = Effect.suspend(() => run(globalThis.process.argv));
 
main.pipe(
  Effect.provide(BunContext.layer),
  Effect.tapErrorCause(Effect.logError),
  Runtime.runMain
);


$ bun run test.ts --test one --test two
{
  testOption: [ "one", "two" ],
}
$ bun run test.ts -T one -T two
Expected to find option: '--test'
 
timestamp=2024-01-22T20:49:10.815Z level=ERROR fiber=#12 cause="Error: {\"_tag\":\"MissingValue\",\"error\":{\"_tag\":\"Paragraph\",\"value\":{\"_tag\":\"Text\",\"value\":\"Expected to find option: '--test'\"}}}"
timestamp=2024-01-22T20:49:10.816Z level=ERROR fiber=#12 cause="Error: {\"_tag\":\"MissingValue\",\"error\":{\"_tag\":\"Paragraph\",\"value\":{\"_tag\":\"Text\",\"value\":\"Expected to find option: '--test'\"}}}"
Was this page helpful?