Skip to content

Commit

Permalink
improve example
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanniser committed Oct 20, 2024
1 parent 496b500 commit 98d8162
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions scripts/setup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Command, Prompt } from "@effect/cli";
import { Command, Options, Prompt } from "@effect/cli";
import { NodeContext, NodeRuntime } from "@effect/platform-node";
import { Effect } from "effect";
import { Config, Effect } from "effect";

const colorPrompt = Prompt.select({
message: "Pick your favorite color",
Expand Down Expand Up @@ -58,7 +58,18 @@ const prompt = Prompt.all([
togglePrompt,
]);

const command = Command.prompt("favorites", prompt, Effect.log);
const testOption = Options.boolean("test").pipe(
Options.withAlias("t"),
Options.withFallbackConfig(Config.boolean("TEST")),
);

const command = Command.make("favorites", { testOption }, (args) =>
Effect.gen(function* () {
yield* Effect.log(args);
const promptResults = yield* prompt;
yield* Effect.log(promptResults);
}),
);

const cli = Command.run(command, {
name: "Prompt Examples",
Expand Down

0 comments on commit 98d8162

Please sign in to comment.