Skip to content

Commit

Permalink
[installer] Add default configuration flag (#860)
Browse files Browse the repository at this point in the history
  • Loading branch information
nrybowski committed Sep 12, 2022
1 parent cad231e commit 0c52359
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion inginious-install
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import inginious.frontend.installer
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Creates a configuration file for the specified frontend.')
parser.add_argument("--file", help="Path to configuration file. If not set, use the default for the given frontend.")
parser.add_argument("--default", action='store_true', default=False, help="Set all questions to default value.")
args = parser.parse_args()

inginious.frontend.installer.Installer(args.file).run()
inginious.frontend.installer.Installer(args.file, args.default).run()
10 changes: 7 additions & 3 deletions inginious/frontend/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@
class Installer:
""" Custom installer for the WebApp frontend """

def __init__(self, config_path=None):
def __init__(self, config_path=None, default=False):
self._config_path = config_path
self._default = default

#######################################
# Display functions #
Expand Down Expand Up @@ -73,9 +74,12 @@ def _display_big_warning(self, content):

def _ask_with_default(self, question, default=""):
default = str(default)
answer = input(DOC + UNDERLINE + question + " [" + default + "]:" + ENDC + " ")
if answer == "":
if self._default:
answer = default
else:
answer = input(DOC + UNDERLINE + question + " [" + default + "]:" + ENDC + " ")
if answer == "":
answer = default
return answer

def _ask_boolean(self, question, default):
Expand Down

0 comments on commit 0c52359

Please sign in to comment.