|
@@ -8,19 +8,22 @@ import tap
|
|
|
import cache
|
|
import cache
|
|
|
|
|
|
|
|
class Args(tap.Tap):
|
|
class Args(tap.Tap):
|
|
|
|
|
+ planets: list[str]
|
|
|
sector: tuple[str, ...] = ()
|
|
sector: tuple[str, ...] = ()
|
|
|
|
|
|
|
|
|
|
+ def configure(self) -> None:
|
|
|
|
|
+ self.add_argument('planets', nargs='+', metavar='planet') # take planets as positional args instead of flag
|
|
|
|
|
+
|
|
|
def main() -> None:
|
|
def main() -> None:
|
|
|
args = Args().parse_args()
|
|
args = Args().parse_args()
|
|
|
- planets = []
|
|
|
|
|
if args.sector:
|
|
if args.sector:
|
|
|
all_planets: typing.Sequence[Planet] = cache.get('https://rest.fnar.net/planet/allplanets')
|
|
all_planets: typing.Sequence[Planet] = cache.get('https://rest.fnar.net/planet/allplanets')
|
|
|
for planet in all_planets:
|
|
for planet in all_planets:
|
|
|
if planet['PlanetNaturalId'].startswith(args.sector):
|
|
if planet['PlanetNaturalId'].startswith(args.sector):
|
|
|
- planets.append(planet['PlanetName'])
|
|
|
|
|
|
|
+ args.planets.append(planet['PlanetName'])
|
|
|
|
|
|
|
|
with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
|
|
with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
|
|
|
- for planet, bases in zip(planets, executor.map(get_bases, planets)):
|
|
|
|
|
|
|
+ for planet, bases in zip(args.planets, executor.map(get_bases, args.planets)):
|
|
|
print(planet)
|
|
print(planet)
|
|
|
for base in bases:
|
|
for base in bases:
|
|
|
if base['OwnerCode'] is None:
|
|
if base['OwnerCode'] is None:
|