Skip to content

Commit

Permalink
Fixed help messages of the parent parser
Browse files Browse the repository at this point in the history
  • Loading branch information
lamsoa729 committed Dec 21, 2023
1 parent ab9b782 commit 17ab91d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions chi_pet/chi_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@


def parse_chi_options():
parser = argparse.ArgumentParser(prog='chi.py')

parent_parser = argparse.ArgumentParser(add_help=False)

parent_parser.add_argument('-a', '--args_file', type=Path,
Expand All @@ -26,6 +24,8 @@ def parse_chi_options():
parent_parser.add_argument('-s', '--states', nargs='+', type=str,
help='Name of all the states the simulation will run eg. start, build, analyze, etc.')

parser = argparse.ArgumentParser(prog='chi.py', parents=[parent_parser])

# TODO add prep functionality
parser.add_argument('-P', '--prep', action='store_true',
help='Prepares simulationss to run with either states specified with -s or all argument states in --args_file.')
Expand Down
2 changes: 1 addition & 1 deletion chi_pet/chi_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from .chi_lib import load_yaml_in_order, dump_yaml_in_order
import argparse
from pathlib import Path
from .chi_parse import chi_parse
from .chi_parse import parse_chi_options

'''
Name: ChiMain.py
Expand Down
4 changes: 4 additions & 0 deletions tests/test_chi_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ def test_chi_run_argument_parsing():
sys.argv = ['chi', 'run', '-a', 'args.yaml']
opts = parse_chi_options()
assert opts.args_file == Path('args.yaml')

sys.argv = ['chi', 'run']
with pytest.raises(SystemExit):
opts = parse_chi_options()

0 comments on commit 17ab91d

Please sign in to comment.