doomcc/dcc/ls.py

25 lines
780 B
Python

import dcc.config
import os
class List(dcc.config.Base):
def get_parser(self, prog_name):
parser = super().get_parser(prog_name)
parser.add_argument("target")
parser.add_argument("--wad")
return parser
def take_action(self, parsed_args):
match parsed_args.target:
case "pwads":
self.list(x.name for x in os.scandir(self.pwads) if x.is_dir())
case "iwads":
self.list(x.name for x in os.scandir(self.iwads) if x.is_file())
case "demos":
self.list(x.name for x in os.scandir(self.demos.joinpath(parsed_args.wad)) if x.name.endswith(".lmp"))
case "videos":
self.list(x.name for x in os.scandir(self.output.joinpath(parsed_args.wad)) if x.name.endswith(".mp4"))
def list(self, gen):
# TODO: fancy text?
for i in sorted(gen):
print(i)