feat: support of password type
This commit is contained in:
parent
fee60fc00a
commit
da16ffffc8
3 changed files with 22 additions and 1 deletions
2
src/rougail/user_data_questionary/__init__.py
Normal file
2
src/rougail/user_data_questionary/__init__.py
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
from .data import RougailUserDataQuestionary
|
||||||
|
__all__ = ('RougailUserDataQuestionary',)
|
|
@ -34,8 +34,18 @@ questionary:
|
||||||
{% endif %}
|
{% endif %}
|
||||||
mandatory:
|
mandatory:
|
||||||
description: Ask values only for mandatories variables without any value
|
description: Ask values only for mandatories variables without any value
|
||||||
|
negative_description: Ask values all variables
|
||||||
alternative_name: qm
|
alternative_name: qm
|
||||||
default: false
|
default: false
|
||||||
|
show_secrets:
|
||||||
|
description: Show secrets instead of obscuring them
|
||||||
|
negative_description: Obscuring secrets instead of show them
|
||||||
|
alternative_name: qs
|
||||||
|
type: boolean
|
||||||
|
default:
|
||||||
|
type: variable
|
||||||
|
variable: __.exporter.show_secrets
|
||||||
|
optional: true
|
||||||
"""
|
"""
|
||||||
return {'name': 'questionary',
|
return {'name': 'questionary',
|
||||||
'process': 'user data',
|
'process': 'user data',
|
||||||
|
|
|
@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
from rougail.object_model import CONVERT_OPTION
|
from rougail.object_model import CONVERT_OPTION
|
||||||
from rougail.config import RougailConfig
|
from rougail.config import RougailConfig
|
||||||
from tiramisu.error import ValueOptionError
|
from tiramisu.error import ValueOptionError
|
||||||
from questionary import text, select, confirm, Validator, ValidationError, print as qprint
|
from questionary import text, select, confirm, password, Validator, ValidationError, print as qprint
|
||||||
|
|
||||||
class RougailUserDataQuestionary:
|
class RougailUserDataQuestionary:
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
|
@ -33,6 +33,13 @@ class RougailUserDataQuestionary:
|
||||||
self.config = config
|
self.config = config
|
||||||
if rougailconfig is None:
|
if rougailconfig is None:
|
||||||
rougailconfig = RougailConfig
|
rougailconfig = RougailConfig
|
||||||
|
user_data = rougailconfig['step.user_data']
|
||||||
|
if 'questionary' not in user_data:
|
||||||
|
user_data.append('questionary')
|
||||||
|
rougailconfig['step.user_data'] = user_data
|
||||||
|
user_data = rougailconfig['step.user_data']
|
||||||
|
if 'questionary' not in user_data:
|
||||||
|
raise Exception('questionary is not set in step.user_data')
|
||||||
self.rougailconfig = rougailconfig
|
self.rougailconfig = rougailconfig
|
||||||
self.errors = []
|
self.errors = []
|
||||||
self.warnings = []
|
self.warnings = []
|
||||||
|
@ -92,6 +99,8 @@ class RougailUserDataQuestionary:
|
||||||
kwargs['choices'] = option.value.list()
|
kwargs['choices'] = option.value.list()
|
||||||
elif option_type == 'boolean':
|
elif option_type == 'boolean':
|
||||||
question_funtion = confirm
|
question_funtion = confirm
|
||||||
|
elif option_type == 'secret' and not self.rougailconfig['questionary.show_secrets']:
|
||||||
|
question_funtion = password
|
||||||
else:
|
else:
|
||||||
question_funtion = text
|
question_funtion = text
|
||||||
kwargs['validate'] = RougailValidator
|
kwargs['validate'] = RougailValidator
|
||||||
|
|
Loading…
Reference in a new issue