diff --git a/src/sorcha/sorcha.py b/src/sorcha/sorcha.py index c36b1327..0c1087af 100755 --- a/src/sorcha/sorcha.py +++ b/src/sorcha/sorcha.py @@ -183,7 +183,6 @@ def runLSSTSimulation(args, sconfigs): if sconfigs.input.ephemerides_type.casefold() == "external": verboselog("Reading in chunk of orbits and associated ephemeris from an external file") observations = reader.read_block(block_size=sconfigs.input.size_serial_chunk) - observations.to_csv("post_readin_ephem_nonprimary.csv") else: verboselog("Ingest chunk of orbits") orbits_df = reader.read_aux_block(block_size=sconfigs.input.size_serial_chunk) diff --git a/src/sorcha_cmdline/bootstrap.py b/src/sorcha_cmdline/bootstrap.py index dbb527e5..b3545b7c 100644 --- a/src/sorcha_cmdline/bootstrap.py +++ b/src/sorcha_cmdline/bootstrap.py @@ -1,15 +1,17 @@ # # The `sorcha run` subcommand implementation # -import argparse import pooch +from sorcha_cmdline.sorchaargumentparser import SorchaArgumentParser def main(): # pragma: no cover # parse the input arguments - parser = argparse.ArgumentParser( - description="Fetch the NAIF high precision EOP kernel file store its checksum." + parser = SorchaArgumentParser( + prog="sorcha bootstrap", + description="Fetch the NAIF high precision EOP kernel file store its checksum.", ) + parser.add_argument( "--cache", type=str, diff --git a/src/sorcha_cmdline/demo.py b/src/sorcha_cmdline/demo.py index 1b1744f4..6b9d4323 100644 --- a/src/sorcha_cmdline/demo.py +++ b/src/sorcha_cmdline/demo.py @@ -1,4 +1,4 @@ -import argparse +from sorcha_cmdline.sorchaargumentparser import SorchaArgumentParser # # sorcha demo prepare @@ -47,11 +47,14 @@ def cmd_demo_howto(args): # pragma: no cover def main(): # Create the top-level parser - parser = argparse.ArgumentParser( - prog="sorcha-demo", description="Prepare and explain how to run sorcha demos" + parser = SorchaArgumentParser( + prog="sorcha demo", description="Prepare and explain how to run sorcha demos" ) subparsers = parser.add_subparsers( - title="commands", description="Available commands", help="Command to execute", dest="command" + title="commands", + description="Available commands", + help="Command to execute", + dest="command", ) # Add the `prepare` subcommand diff --git a/src/sorcha_cmdline/init.py b/src/sorcha_cmdline/init.py index 1961b370..e60f7948 100644 --- a/src/sorcha_cmdline/init.py +++ b/src/sorcha_cmdline/init.py @@ -1,4 +1,4 @@ -import argparse +from sorcha_cmdline.sorchaargumentparser import SorchaArgumentParser import sys # @@ -72,8 +72,8 @@ def execute(args): # pragma: no cover def main(): # Create the top-level parser - parser = argparse.ArgumentParser( - prog="sorcha-init", description="Initialize configuration files for a new simulation." + parser = SorchaArgumentParser( + prog="sorcha init", description="Initialize configuration files for a new simulation." ) parser.add_argument("-v", "--verbose", action="store_true", help="Enable verbose output") parser.add_argument( diff --git a/src/sorcha_cmdline/outputs.py b/src/sorcha_cmdline/outputs.py index 33fa0858..4483f089 100644 --- a/src/sorcha_cmdline/outputs.py +++ b/src/sorcha_cmdline/outputs.py @@ -1,4 +1,4 @@ -import argparse +from sorcha_cmdline.sorchaargumentparser import SorchaArgumentParser # # sorcha outputs create-sqlite @@ -69,7 +69,7 @@ def cmd_outputs_check_logs(args): # pragma: no cover def main(): # Create the top-level parser - parser = argparse.ArgumentParser(prog="sorcha-outputs", description="Sorcha outputs manipulation utility") + parser = SorchaArgumentParser(prog="sorcha outputs", description="Sorcha outputs manipulation utility") subparsers = parser.add_subparsers( title="commands", description="Available commands", help="Command to execute", dest="command" ) diff --git a/src/sorcha_cmdline/run.py b/src/sorcha_cmdline/run.py index b79767fc..74fbd7f3 100644 --- a/src/sorcha_cmdline/run.py +++ b/src/sorcha_cmdline/run.py @@ -2,12 +2,18 @@ # The `sorcha run` subcommand implementation # import argparse +from sorcha_cmdline.sorchaargumentparser import SorchaArgumentParser def main(): - parser = argparse.ArgumentParser( - formatter_class=argparse.ArgumentDefaultsHelpFormatter, description="Run a simulation." + parser = SorchaArgumentParser( + prog="sorcha run", + formatter_class=argparse.ArgumentDefaultsHelpFormatter, + description="Run a simulation.", ) + + # parser = SorchaArgparse(parser) + required = parser.add_argument_group("Required arguments") required.add_argument( "-c", diff --git a/src/sorcha_cmdline/sorchaargumentparser.py b/src/sorcha_cmdline/sorchaargumentparser.py new file mode 100644 index 00000000..313355e9 --- /dev/null +++ b/src/sorcha_cmdline/sorchaargumentparser.py @@ -0,0 +1,37 @@ +from argparse import ArgumentParser + + +class SorchaArgumentParser(ArgumentParser): + """A subclass of the argparse.ArgumentParser that adds in a print statement + to make it clearer how to get detailed help for new users who may not be + as familiar with linux/unix""" + + def __init__(self, *args, **kwargs): + """A subclass of the argparse.ArgumentParser that adds in a print statement + to make it clearer how to get detailed help for new users who may not be + as familiar with linux/unix + + Parameters + ----------- + *args: Variable length argument list. + **kwargs: Arbitrary keyword arguments. + """ + super().__init__(*args, **kwargs) + + def print_usage(self, file=None): + """Print a brief description of how the ArgumentParser should be invoked + on the command line. If file is None, sys.stdout is assumed. + + + Parameters + ----------- + file: str or None + Variable length argument list. + + Returns + ----------- + None. + + """ + super().print_usage(file) + print(f"For more detailed help try: {self.prog} -h ", file=file)