Closed joepjoosten closed 6 days ago
Latest commit: bdf225420c8dbd261d471da8e70a0cdc218aed9d
The changes in this PR will be included in the next version bump.
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Scratchpad to see it in action:
import { Command, Prompt } from "@effect/cli"
import { NodeContext, NodeRuntime } from "@effect/platform-node"
import { Array, Console, Effect, pipe } from "effect"
const run = Command.make("example", {}, () =>
Effect.gen(function*() {
const choices = pipe(Array.range(1, 20), Array.map((n) => ({ title: `Option ${n}`, value: n })))
const selectMulti = yield* Prompt.selectMulti({
message: "select a option",
choices
})
yield* Console.log(`You selected: ${selectMulti.join(", ")}`)
})).pipe(
Command.run({
name: "Test",
version: "1.0.0"
})
)
const main = Effect.suspend(() => run(globalThis.process.argv))
main.pipe(
Effect.provide(NodeContext.layer),
Effect.tapErrorCause(Effect.logError),
NodeRuntime.runMain
)
@joepjoosten - thank you so much for all the work you put into this! It looks great so far! I did notice one small thing that I wanted to get your opinion on.
If I select a bunch of options, then invert the selection, and then select all the options, the returned results are out-of-order:
It might be a good idea if we order the results by option number on submission before returning the final list. Wdyt?
@joepjoosten - this looks good to me! The only additional request I have is that we make this a patch release since we're only adding a feature, which is backward compatible.
Thanks!
Should i add min/max choices support? Then it can be used in the wizard when there is a repeated choice option?
Sure! That would be a cool addition :)
I'm also not really fond of using default text for the select all/none and inverse selection. This is not very international because there in English. I don't know if there are universal symbols for select all/none and inverse?
And nothing more difficult than naming things: "selectMulti", i'm still not happy with this name...
And nothing more difficult than naming things: "selectMulti", i'm still not happy with this name...
Maybe MultiSelect
instead?
I've added the min max functionality, and renamed it to multiSelect
The only additional request I have is that we make this a patch release since we're only adding a feature, which is backward compatible.
@joepjoosten - only one thing left to take care of before we can merge this in 👍
Sorry, i missed that comment. Is this what you mean? (see latest commit)
Thanks @joepjoosten !
Type
Description
Added prompt to select multiple choices