From f5b269e3a4482ff1d03dfddcdfb6775d872d9331 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Sun, 14 Jul 2019 12:09:16 +1000 Subject: [PATCH] plan.py: add commandline parsing --- plan.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/plan.py b/plan.py index 956c03a..cd3d761 100755 --- a/plan.py +++ b/plan.py @@ -38,7 +38,8 @@ def required_rates( while remain: for dst_name, dst_rate in remain.pop().items(): - # Append the requested item + # Append the requested item to the output rate. We'll add the + # inputs just below. required_items[dst_name] += dst_rate # We can't craft resources, so just ignore them. @@ -148,13 +149,22 @@ def plan(recipes: satisfactory.Cookbook, required: Dict[str, Fraction]): def main(): recipes = satisfactory.Cookbook('data/recipes') - # Create a list of items we want to make - # names = [ 'supercomputer' ] - names = recipes.components() + import argparse + + parser = argparse.ArgumentParser() + parser.add_argument( + "item", + nargs="*", + type=str, + default=recipes.components(), + help="The name of an item to produce at full rate" + ) + + args = parser.parse_args() # Create an initial name:rate request for all of the target items, then # create a plan for their creation. - request = [{n: basic_rate(recipes[n]['recipes'][0]) for n in names}] + request = [{n: basic_rate(recipes[n]['recipes'][0]) for n in args.item}] plan(recipes, request)