doomcc/dcc/ls.py

45 lines
1.4 KiB
Python
Raw Normal View History

import dcc.config
import os
2025-06-15 12:18:46 -04:00
class List(dcc.config.ListerBase):
2025-06-15 12:18:46 -04:00
def get_parser(self, prog_name):
parser = super().get_parser(prog_name)
parser.add_argument("target")
parser.add_argument("--wad")
return parser
2025-06-15 12:18:46 -04:00
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()
)
)
2025-06-15 12:18:46 -04:00
case "iwads":
return (
("iwads",), sorted(
2025-09-01 17:32:19 -04:00
(x.name,) for x in
os.scandir(self.iwads) if x.is_file()
)
2025-06-15 12:18:46 -04:00
)
case "demos":
return (
("demos",), sorted(
(x.name,) for x in
os.scandir(self.demos.joinpath(parsed_args.wad))
if x.name.endswith(".lmp")
)
2025-06-15 12:18:46 -04:00
)
case "videos":
return (
("videos",), sorted(
(x.name,) for x in
os.scandir(self.fabricate.joinpath(parsed_args.wad))
if x.name.endswith(".mp4")
)
2025-06-15 12:18:46 -04:00
)
case _:
raise Exception(f"unknown target {parsed_args.target}")