-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Please, inform which are the valid values in docs advanced/boolean_variables.html #1695
Comments
Hi @italomaia, are you asking about this feature? In json specification it is only |
I think the question is not what you can specify in json, but what users can specify on the command line for true/false during generation. The question I have also asked myself, what all works there? |
@insspb I refer to the user input. Documentation informs how to create an boolean configuration but not what counts as a true or false user input. Is there any pre-procession? Does the user have to write specifically True or False when prompted? |
Good question. For Python projects in general (not specifically about cookiecutter) I use this implementation to deal with boolean values when having user input: TRUE_VALUES = {'y', 'yes', 't', 'true', 'on', '1'}
FALSE_VALUES = {'n', 'no', 'f', 'false', 'off', '0'}
def strtobool(value):
if isinstance(value, bool):
return value
value = value.lower()
if value in TRUE_VALUES:
return True
elif value in FALSE_VALUES:
return False
raise ValueError(f'Invalid truth value: {value}') That said, I don't know whether or not it would be nice to support such a "wide" set of options. |
@luzfcb which is reasonable. We need clarity regarding how cookiecutter does it. Can the ticket be rebranded, as it is not a question? |
@italomaia I guess it is only necessary to update the documentation. cookiecutter/cookiecutter/prompt.py Lines 23 to 33 in 5ea9522
|
Indeed. MR available: #1705 |
@italomaia @luzfcb Thank you for contribution and asking this question. Updated docstrings and documentation. Check as 'latest' hope now everything clear. |
Description:
Could you please inform which are the valid values for a boolean configuration variable? Will "y" coerce to True? What about "yes"? What about "n" and "no"? What about "true"?
The text was updated successfully, but these errors were encountered: