magmax / python-inquirer

A collection of common interactive command line user interfaces, based on Inquirer.js (https://github.com/SBoudrias/Inquirer.js/)
MIT License
992 stars 98 forks source link

Added lenlimit feature for List() and Checkbox() #539

Closed hsiang086 closed 2 months ago

hsiang086 commented 5 months ago

Hi

This added a feature to List() and Checkbox()

import inquirer
from pprint import pprint
questions = [
  inquirer.List('size',
                message="What size do you need?",
                choices=['Jumbo', 'Large', 'Standard', 'Medium', 'Small', 'Micro'],
                lenlimit=3,
                ),
  inquirer.Checkbox('interests',
                    message="What are you interested in?",
                    choices=['Computers', 'Books', 'Science', 'Nature', 'Fantasy', 'History'],
                    lenlimit=3,
                    ),
]
answers = inquirer.prompt(questions)
pprint(answers)
Screenshot 2024-03-06 at 3 00 26 AM
Cube707 commented 5 months ago

I don't really get why this is relevant? You can just filter the choices input befor/when passing it into inqurie?

And for the rare case you need a global filter that automatically applies to all prompts, MAX_OPTIONS_DISPLAYED_AT_ONCE exisits (and gets removed by you)

Cube707 commented 5 months ago

also this breaks MAX_OPTIONS_DISPLAYED_AT_ONCE, which is bad

Cube707 commented 5 months ago

@hsiang086 do you want to elaborate your reasoning? if you have a valid usecase I am open to discussion? Its just that I don't see a need for this

If not I will close the PR