Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prompt gets cut off if too long #42

Open
alichtman opened this issue Apr 3, 2018 · 7 comments
Open

Prompt gets cut off if too long #42

alichtman opened this issue Apr 3, 2018 · 7 comments
Labels
bug Something isn't working

Comments

@alichtman
Copy link

screen shot 2018-04-03 at 8 14 56 am

I looked through the documentation and didn't see a workaround for this. Do you have any suggestions?

@magmax
Copy link
Owner

magmax commented Apr 3, 2018

I'm afraid there isn't. Maybe it should manage two lines, but currently it cannot.

@alichtman
Copy link
Author

alichtman commented Apr 3, 2018

I wrote a quick workaround for it. I'm also using colorama and this works:

def prompt_yes_no(top_line="", bottom_line="",):
	"""Print question (split into top and bottom lines) and return True or False 
depending on user selection from list. bottom_line should be used for one liners, 
with an empty top_line. Otherwise, bottom_line is the second line you want printed."""

	if top_line is not "":
		print(Fore.GREEN + Style.BRIGHT + " " + top_line)

	questions = [ inquirer.List('choice',
	                            message=Fore.GREEN + Style.BRIGHT + bottom_line + Fore.YELLOW,
	                            choices=[' Yes', ' No'],
	                            ),
	]

	answers = inquirer.prompt(questions)

	if answers.get('choice').strip() == 'Yes':
		return True
	else:
		return False

Feel free to add this to the documentation. I think many people (myself included) would have found this tip helpful.

@AuHau AuHau added the bug Something isn't working label Mar 5, 2019
@lhriley
Copy link

lhriley commented Aug 18, 2020

@magmax

This is causing me problems as well. I believe that the textwrap module might be a viable solution: https://docs.python.org/3/library/textwrap.html

I would put up a PR, but I read through the code briefly and I'm just not sure where best to test it as a general solution. Any insight into the code base would be helpful. Thanks!

@rixx
Copy link

rixx commented Jun 4, 2021

Notably, this bug even occurs when you wrap the text yourself, because the code doesn't include newlines in the text length check.

@alichtman
Copy link
Author

Notably, this bug even occurs when you wrap the text yourself, because the code doesn't include newlines in the text length check.

Correct, that's why my workaround looks so jank. 🤷

@lminer
Copy link

lminer commented Feb 13, 2022

This is pretty key functionality. Putting in a vote that this would be a great new feature.

@trivedip
Copy link

trivedip commented Jun 4, 2024

Wish this was fixed, this seems like pretty common issue; just registering my vote.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants
@magmax @rixx @lminer @AuHau @lhriley @alichtman @trivedip and others