-
-
Notifications
You must be signed in to change notification settings - Fork 243
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
Prompt multi select #3929
base: main
Are you sure you want to change the base?
Prompt multi select #3929
Conversation
Added tests for select and multi select
Code cleanup
🦋 Changeset detectedLatest commit: bdf2254 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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... |
Maybe |
Removed selectUtils, because not enough in common between select and selectMulti
I've added the min max functionality, and renamed it to multiSelect |
@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) |
Type
Description
Added prompt to select multiple choices