def make_wizard(default_file=None, confirm=False): """Makes a configuration wizard for xonsh config file. Parameters ---------- default_file : str, optional Default filename to save and load to. User will still be prompted. confirm : bool, optional Confirm that the main part of the wizard should be run. """ wiz = Wizard(children=[ Message(message=WIZARD_HEAD), Load(default_file=default_file, check=True), Message(message=WIZARD_FS), make_fs(), Message(message=WIZARD_ENV), YesNo(question=WIZARD_ENV_QUESTION, yes=make_env(), no=Pass()), Message(message=WIZARD_XONTRIB), YesNo(question=WIZARD_XONTRIB_QUESTION, yes=make_xontribs(), no=Pass()), Message(message='\n' + HR + '\n'), Save(default_file=default_file, check=True), Message(message=WIZARD_TAIL), ]) if confirm: q = ("Would you like to run the xonsh configuration wizard now?\n\n" "1. Yes\n2. No, but ask me later.\n3. No, and don't ask me again." "\n\n1, 2, or 3 [default: 2]? ") passer = Pass() saver = Save(check=False, ask_filename=False, default_file=default_file) wiz = Question(q, {1: wiz, 2: passer, 3: saver}, converter=lambda x: int(x) if x != '' else 2) return wiz
def make_wizard(default_file=None, confirm=False): """Makes a configuration wizard for xonsh config file. Parameters ---------- default_file : str, optional Default filename to save and load to. User will still be prompted. confirm : bool, optional Confirm that the main part of the wizard should be run. """ wiz = Wizard(children=[ Message(message=WIZARD_HEAD), Load(default_file=default_file, check=True), Message(message=WIZARD_FS), make_fs(), Message(message=WIZARD_ENV), YesNo(question=WIZARD_ENV_QUESTION, yes=make_env(), no=Pass()), Message(message='\n' + HR + '\n'), Save(default_file=default_file, check=True), Message(message=WIZARD_TAIL), ]) if confirm: q = 'Would you like to run the xonsh configuration wizard now, ' + YN wiz = YesNo(question=q, yes=wiz, no=Pass()) return wiz