unjs / consola

🐨 Elegant Console Logger for Node.js and Browser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Built-in prompt support

pi0 opened this issue · comments

Having an easy way to support console input prompts was always missing.

I have been thinking for a while how we could add it to the consola core without adding to initial bundle load overhead and finally thinking we could have await consola.prompt(message, { type, ... }) that lazily imports the actual prompt utils from consola/prompt subpath.

For implementation, writing from scratch is probably reinventing the wheel while at least there are two awesome options prompts and clack. propts seems more feature rich and tested but it is not updated for a while and has 204kb bundle impact comparing to 38KB bundle impact of clack (core).

Trying clak, i really love the core/theme splited implementation. Only since theme is not customizable to be consistent with consola's styling, I'm thinking to copy @clak/prompts and add styling directly from consola, hoping at some point, we might have an upstream refactor to allow directly using @clak/propmts and be better in sync.

About API, i am thinking to introduce only on simple consola.prompt({ type, message }) util adding types progressively and mapping to the underlying engine.