centreformicrosimulation / SimPaths

SimPaths is an open-source microsimulation framework for life course analysis, developed and maintained by CeMPA at the University of Essex
6 stars 16 forks source link

Experimental/arg parsing #41

Closed andrewbaxter439 closed 10 months ago

andrewbaxter439 commented 10 months ago

This is an experimental tweak to the argument parsing I had put in before. Now it more safely parses arguments (I hope) and can provide a help output on invalid arguments or -h flag:

$ java -jar singlerun.jar -h
usage: SimPathsStart [-c <arg>] [-g <arg>] [-h] [-s <arg>] [-Setup]
SimPathsStart will start the SimPaths run. When using the argument
`Setup`, this will create the population database and exit before starting
the first run. It takes the following options:
 -c <arg>   Country
 -g <arg>   Show GUI [true/false]
 -h         Print help message
 -s <arg>   Start year
 -Setup     Setup only
When running with no display, `-g` must be set to `false`.

and

$ java -jar multirun.jar -h
usage: SimPathsMultiRun [-e <arg>] [-f] [-g <arg>] [-h] [-n <arg>] [-p
       <arg>] [-r <arg>] [-s <arg>]
SimPathsMultiRun can run multiple sequential runs, resetting the
population to the start year and iterating from the start seed. It takes
the following options:
 -e <arg>   End year
 -f         Output to file
 -g <arg>   Show GUI [true/false]
 -h         Print help message
 -n <arg>   Maximum number of runs
 -p <arg>   Population size
 -r <arg>   Random seed
 -s <arg>   Start year
When running with no display, `-g` must be set to `false`.

Added two test files to detect content of help outputs when running each class.

andrewbaxter439 commented 10 months ago

Low priority suggested tweak - only useful to those who wish to follow the cli-run route but hopefully a clarification and improvement on all the confusing bits and pieces I've been putting in so far. Two potential things that could be tweaked (now or in future):

Do let me know if useful as an experimental feature @pbronka

andrewbaxter439 commented 10 months ago

Slight tweaks, help messages now display in helpful order:

$ java -jar singlerun.jar -h
usage: SimPathsStart [-c <UK/IT>] [-s <year>] [-Setup] [-g <true/false>]
       [-h]
SimPathsStart will start the SimPaths run. When using the argument
`Setup`, this will create the population database and exit before starting
the first run. It takes the following options:
 -c <UK/IT>        Country
 -s <year>         Start year
 -Setup            Setup only
 -g <true/false>   Show GUI [true/false]
 -h                Print help message
When running with no display, `-g` must be set to `false`.

$ java -jar multirun.jar -h
usage: SimPathsMultiRun [-p <int>] [-s <year>] [-e <year>] [-n <int>] [-r
       <int>] [-g <true/false>] [-f] [-h]
SimPathsMultiRun can run multiple sequential runs, resetting the
population to the start year and iterating from the start seed. It takes
the following options:
 -p <int>          Population size
 -s <year>         Start year
 -e <year>         End year
 -n <int>          Maximum number of runs
 -r <int>          Random seed
 -g <true/false>   Show GUI
 -f                Output to file
 -h                Print help message
When running with no display, `-g` must be set to `false`.