This requires multiple inheritance and other shenanigans to actually work. I think I'm supposed to do this with hooks. Work for the future.
44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
import dcc.config
|
|
import os
|
|
|
|
|
|
class List(dcc.config.ListerBase):
|
|
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":
|
|
return (
|
|
("pwads",), sorted(
|
|
(x.name,) for x in os.scandir(self.pwads) if x.is_dir()
|
|
)
|
|
)
|
|
case "iwads":
|
|
return (
|
|
("iwads",), sorted(
|
|
(x.name,) for x in os.scandir(self.iwads) if x.is_file()
|
|
)
|
|
)
|
|
case "demos":
|
|
return (
|
|
("demos",), sorted(
|
|
(x.name,) for x in
|
|
os.scandir(self.demos.joinpath(parsed_args.wad))
|
|
if x.name.endswith(".lmp")
|
|
)
|
|
)
|
|
|
|
case "videos":
|
|
return (
|
|
("videos",), sorted(
|
|
(x.name,) for x in
|
|
os.scandir(self.fabricate.joinpath(parsed_args.wad))
|
|
if x.name.endswith(".mp4")
|
|
)
|
|
)
|
|
case _:
|
|
raise Exception(f"unknown target {parsed_args.target}")
|