diff --git a/gridpath/common_functions.py b/gridpath/common_functions.py index 635674f13..94ba314a2 100644 --- a/gridpath/common_functions.py +++ b/gridpath/common_functions.py @@ -76,8 +76,9 @@ def get_scenario_name_parser(): """ parser = ArgumentParser(add_help=False) - parser.add_argument("--scenario", required=True, type=str, - help="Name of the scenario problem to solve.") + required = parser.add_argument_group('required arguments') + required.add_argument("--scenario", required=True, type=str, + help="Name of the scenario problem to solve.") return parser @@ -145,7 +146,7 @@ def get_solve_parser(): "for which you are providing an executable.") parser.add_argument("--mute_solver_output", default=False, action="store_true", - help="Don't print solver output if set to true.") + help="Don't print solver output.") parser.add_argument("--write_solver_files_to_logs_dir", default=False, action="store_true", help="Write the temporary " "solver files to the logs " diff --git a/gridpath/run_scenario.py b/gridpath/run_scenario.py index 853349569..b1018a65e 100644 --- a/gridpath/run_scenario.py +++ b/gridpath/run_scenario.py @@ -798,6 +798,12 @@ def parse_arguments(args): get_solve_parser()] ) + # Flip order of argument groups so "required arguments" show first + # https://stackoverflow.com/questions/39047075/reorder-python-argparse-argument-groups + # Note: hacky fix; preferred answer of creating an explicit optional group + # doesn't work because we combine parsers here with the parents keyword + parser._action_groups.reverse() + # Parse arguments # TODO: should we throw warning for unknown arguments (here and in the # other scripts)? run_start_to_end does pass unknown arguments (e.g.