plan.py: add commandline parsing
This commit is contained in:
parent
f75047dde5
commit
f5b269e3a4
20
plan.py
20
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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user