Closed carlosefonseca closed 6 years ago
Hi Carlos,
The Prompt instance has only configuration that applies to all prompts, that's why :interrupt
, :enable_color
etc... All individual prompts have their unique configuration, especially ask
prompt has many options.
All menu prompts support :cycle
option but many(mask
, ask
, expand
etc...) do not. More importantly, the :cycle
option is switched off by default as this is deemed less than desirable behaviour in menu prompt due to its confusing nature if anything.
Since global state is less than desirable I want to minimise places where potential option overwrite issues may occur, many times forgetting to set thing over there, and not there.
I also feel that being explicit each time you make a decision to use :cycle
makes for readable code.
So this is my reasoning why I haven't added it to global configuration. Have you found this to be an issue in your project?
I got used to just press Up and go the end of the list when I want something from the bottom. I use it a lot for option menus as well as lists with data, nothing huge, but I liked the ability to do Up. I guess I just wanted an easy way to get the old behaviour back without adding a parameter to every select
call. I might just wrap them in a method or something.
Totally understand your case, and that's why the menu prompts cycled by default. However, when making this breaking change I didn't make it lightly, I thought about the 'average' case and the least confusing behaviour. It's easy to imagine a list of many complex items that user is unfamiliar with and wishes to see what's available and, in my opinion, infinite list is the last thing they would expect. There are many more examples such as shell history lookup that do not cycle by default. If future proves me wrong and people will find it troubling then I will be happy to revert it back but for now I'm confident in the decision.
The
cycle
setting that was added on #66 could be added as a setting on the Prompt instance, and with that, only set it once to retain the old wrap around behaviour on every call without having to add the argument on every one.