Reorganize command-line arguments

All arguments are now enclosed in a single argument group to improve the
generated help text.

Due to how argparse works, this means that the script now allows
redundant command-line arguments like specifying the occasional buyer
and explicit buyers.

The grammar of the help text has been made slightly more consistent.
This commit is contained in:
Jeremy Saklad 2021-07-11 13:11:12 -05:00
parent 630d63a555
commit c73023d4dc
Signed by: Jeremy Saklad
GPG Key ID: 9CA2149583EDBF84
1 changed files with 38 additions and 19 deletions

View File

@ -2391,15 +2391,13 @@ def main():
argument_default=argparse.SUPPRESS, argument_default=argparse.SUPPRESS,
) )
parser.add_argument(
"-s", "--shadowy", world_qualities = parser.add_argument_group(
type=int, "world qualities",
required=True, "Parameters shared across Fallen London, often changing on a routine basis"
help="the effective level of Shadowy used for selling to buyers",
dest='shadowy_level'
) )
parser.add_argument( world_qualities.add_argument(
"-f", "--bone-market-fluctuations", "-f", "--bone-market-fluctuations",
action=EnumAction, action=EnumAction,
type=Fluctuation, type=Fluctuation,
@ -2408,7 +2406,7 @@ def main():
dest='bone_market_fluctuations' dest='bone_market_fluctuations'
) )
parser.add_argument( world_qualities.add_argument(
"-m", "--zoological-mania", "-m", "--zoological-mania",
action=EnumAction, action=EnumAction,
type=Declaration, type=Declaration,
@ -2417,23 +2415,37 @@ def main():
dest='zoological_mania' dest='zoological_mania'
) )
buyer = parser.add_mutually_exclusive_group() world_qualities.add_argument(
transient_buyers = buyer.add_argument_group()
transient_buyers.add_argument(
"-o", "--occasional-buyer", "-o", "--occasional-buyer",
action=EnumAction, action=EnumAction,
type=OccasionalBuyer, type=OccasionalBuyer,
help="current value of Occasional Buyer, which allows access to a buyer that is not otherwise available", help="current value of Occasional Buyer, which allows access to a buyer that is not otherwise available",
dest='occasional_buyer' dest='occasional_buyer'
) )
transient_buyers.add_argument(
world_qualities.add_argument(
"-d", "--diplomat-fascination", "-d", "--diplomat-fascination",
action=EnumAction, action=EnumAction,
type=DiplomatFascination, type=DiplomatFascination,
help="current value of The Diplomat's Current Fascination, which determines what the Trifling Diplomat is interested in", help="current value of The Diplomat's Current Fascination, which determines what the Trifling Diplomat is interested in",
dest='diplomat_fascination' dest='diplomat_fascination'
) )
buyer.add_argument(
skeleton_parameters = parser.add_argument_group(
"skeleton parameters",
"Parameters that determine what you want the solver to produce"
)
skeleton_parameters.add_argument(
"-s", "--shadowy",
type=int,
required=True,
help="the effective level of Shadowy used for selling to buyers",
dest='shadowy_level'
)
skeleton_parameters.add_argument(
"-b", "--buyer", "--desired-buyer", "-b", "--buyer", "--desired-buyer",
action=EnumAction, action=EnumAction,
nargs='+', nargs='+',
@ -2442,21 +2454,27 @@ def main():
dest='desired_buyers' dest='desired_buyers'
) )
parser.add_argument( skeleton_parameters.add_argument(
"-c", "--cost", "--maximum-cost", "-c", "--cost", "--maximum-cost",
type=int, type=int,
help="maximum number of pennies that should be invested in skeleton", help="maximum number of pennies that should be invested in skeleton",
dest='maximum_cost' dest='maximum_cost'
) )
parser.add_argument( skeleton_parameters.add_argument(
"-e", "--exhaustion", "--maximum_exhaustion", "-e", "--exhaustion", "--maximum_exhaustion",
type=int, type=int,
help="maximum exhaustion that skeleton should generate", help="maximum exhaustion that skeleton should generate",
dest='maximum_exhaustion' dest='maximum_exhaustion'
) )
parser.add_argument(
solver_options = parser.add_argument_group(
"solver options",
"Options that affect how the solver behaves"
)
solver_options.add_argument(
"-v", "--verbose", "-v", "--verbose",
action='store_true', action='store_true',
default=False, default=False,
@ -2464,20 +2482,21 @@ def main():
dest='verbose' dest='verbose'
) )
parser.add_argument( solver_options.add_argument(
"-t", "--time-limit", "-t", "--time-limit",
type=float, type=float,
help="maximum number of seconds that solver runs for", help="maximum number of seconds that the solver runs for",
dest='time_limit' dest='time_limit'
) )
parser.add_argument( solver_options.add_argument(
"-w", "--workers", "-w", "--workers",
type=int, type=int,
help="number of search worker threads to run in parallel (default: one worker per available CPU thread)", help="number of search worker threads to run in parallel (default: one worker per available CPU thread)",
dest='workers' dest='workers'
) )
args = parser.parse_args() args = parser.parse_args()
arguments = vars(args) arguments = vars(args)