bombshell-dev / clack

Effortlessly build beautiful command-line apps
https://clack.cc
5.23k stars 88 forks source link

feat(@clack/core,@clack/prompts): Adding a new warn state to the validate method #198

Open hcl-z opened 2 weeks ago

hcl-z commented 2 weeks ago

At present, validate method can only return a string, and can only indicate a state (error state), but sometimes you may just want to remind the user of some precautions rather than directly preventing the user to continue to execute the programme, so I modified the type of return of validate method.

export type ValidateType = ((value: any) => ({ status: 'error' | 'warn', message: string } | void));

The error and warn states are triggered in the same way, the difference between the two is that the terminal won't stop the user from continuing after the warn is triggered, you just need to press Enter again to pass the current option.

https://github.com/bombshell-dev/clack/assets/60871037/1a6d2f79-5284-48bf-b1db-e41730a7417b