mordant icon indicating copy to clipboard operation
mordant copied to clipboard

Specify minimum required selected elements in interactiveMultiSelectList

Open mikaelstaldal opened this issue 3 months ago • 3 comments

It would be useful to be able to specify minimum required selected elements in Terminal.interactiveMultiSelectList().

mikaelstaldal avatar Nov 13 '25 09:11 mikaelstaldal

If you're using it through Clikt, you can add a validate to the option to check the length of the list.

What would you want the behavior to be if the minimum was specified on the list?

ajalt avatar Nov 13 '25 17:11 ajalt

What would you want the behavior to be if the minimum was specified on the list?

The user should not be able to complete the selection with [ENTER] unless at least the minimum number of elements are selected. Similar to that you can now specify the maximum allowed with limit.

mikaelstaldal avatar Nov 14 '25 08:11 mikaelstaldal

If you're using it through Clikt, you can add a validate to the option to check the length of the list.

I'm using Clikt in the same app, but I am not using interactiveMultiSelectList in a Clikt option, so I don't think that would work for me.

This is how I am using it (open source): https://gitlab.com/chromaway/core-tools/management-console/-/blob/386b25c39885d785eac4b0c309996c4e284d4232/src/main/kotlin/net/postchain/mc/cli/DCBaseCommand.kt#L96-99

(In this case I want to force the user to select exactly neededAdditionalKeys elements.)

mikaelstaldal avatar Nov 14 '25 08:11 mikaelstaldal