diff --git a/WorkbenchConfig.py b/WorkbenchConfig.py index d68d822..4781727 100644 --- a/WorkbenchConfig.py +++ b/WorkbenchConfig.py @@ -285,6 +285,7 @@ def get_default_config(self): "csv_value_templates_for_paged_content": [], "csv_value_templates_rand_length": 5, "allow_csv_value_templates_if_field_empty": [], + "remind_user_to_run_check": False, } # Tests validity and existence of configuration file path. diff --git a/workbench b/workbench index 562509b..44a2925 100755 --- a/workbench +++ b/workbench @@ -3439,6 +3439,11 @@ parser.add_argument( parser.add_argument( "--contactsheet", help="Generate a contact sheet.", action="store_true" ) +parser.add_argument( + "--skip_user_prompts", + help='Include to skip any user prompts defined in your config file\'s "user_prompts" setting.', + action="store_true", +) parser.add_argument("--version", action="version", version="Islandora Workbench 0.0.0") args = parser.parse_args() @@ -3458,8 +3463,22 @@ except Exception as e: sys.exit(str(e)) config = workbench_config.get_config() +if args.check is not True and config["remind_user_to_run_check"] is True: + if args.skip_user_prompts is not True: + user_has_run_check = input("Have you run --check? (y/n)") + if user_has_run_check.lower() != "y": + logging.info( + 'User was prompted whether they ran --check, and they responded "n".' + ) + sys.exit( + "Your Workbench configuration file indicates you were to be reminded to run --check." + ) + create_temp_dir(config) +if "user_prompts" in config and args.skip_user_prompts is not True: + prompt_user(config) + if config["secondary_tasks"] is not None and len(config["secondary_tasks"]) > 0: secondary_tasks = [] for secondary_config_file in config["secondary_tasks"]: diff --git a/workbench_utils.py b/workbench_utils.py index faedff0..9566fde 100644 --- a/workbench_utils.py +++ b/workbench_utils.py @@ -11138,3 +11138,13 @@ def unzip_archive(config, archive_file_path): message = f'Zip archive "{archive_file_path}" not extracted to "{config["input_dir"]}": cannot find zip archive.' logging.error(message) sys.exit("Error: " + message) + + +def prompt_user(config): + for user_prompt in config["user_prompts"]: + response = input(user_prompt) + if response.lower() != "y": + logging.info( + f'Exiting because user responded "{response}" to prompt "{user_prompt}".' + ) + sys.exit("Exiting at user prompts.")