-
-
Notifications
You must be signed in to change notification settings - Fork 405
CLI: add Prompt.spinner #5404
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
base: main
Are you sure you want to change the base?
CLI: add Prompt.spinner #5404
Conversation
|
Love it! 🎉 |
Awesome!! Would be really cool to also support concurrency / multiple spinners.. 👀 |
import { Console, Effect } from "effect" | ||
|
||
// Demonstration of success, failure, and custom final messages | ||
const program = Effect.gen(function*() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there are a bunch of compilation errors in the example here.
export const spinner = <A, E, R>( | ||
message: string, | ||
effect: Effect.Effect<A, E, R>, | ||
options?: SpinnerOptions<E, A> | ||
): Effect.Effect<A, E, R | Terminal.Terminal> => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make this signature dual - I can help with that if you're unsure, sometimes getting the signature right with an optional third param can be tricky.
const indexRef = yield* Ref.make(0) | ||
const exitRef = yield* Ref.make<Option.Option<Exit.Exit<A, E>>>(Option.none()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since these are only ever accessed / modified within the generator, they can be plain mutable variables.
const indexRef = yield* Ref.make(0) | |
const exitRef = yield* Ref.make<Option.Option<Exit.Exit<A, E>>>(Option.none()) | |
const index = 0 | |
const exit: Exit.Exit<A, E> | undefined = undefined |
7d63555
to
731b16f
Compare
Type
Description
Added a spinner to
Prompt
that animates a spinner while an effect is running.The message is updated when the effect completes successfully or fails.