Read values out of a config file instead of hardcoding them. Further streamline common tasks in a new base config class.
This commit is contained in:
parent
606f27185c
commit
057ac98843
11 changed files with 83 additions and 69 deletions
11
dcc/ls.py
11
dcc/ls.py
|
@ -1,8 +1,7 @@
|
|||
import cliff.command
|
||||
import dcc.config
|
||||
import os
|
||||
|
||||
class List(cliff.command.Command):
|
||||
class List(dcc.config.Base):
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
parser.add_argument("target")
|
||||
|
@ -12,13 +11,13 @@ class List(cliff.command.Command):
|
|||
def take_action(self, parsed_args):
|
||||
match parsed_args.target:
|
||||
case "pwads":
|
||||
self.list(x.name for x in os.scandir(dcc.config.PWADS) if x.is_dir())
|
||||
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(dcc.config.IWADS) if x.is_file())
|
||||
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(dcc.config.DEMOS.joinpath(parsed_args.wad)) if x.name.endswith(".lmp"))
|
||||
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(dcc.config.OUTPUT.joinpath(parsed_args.wad)) if x.name.endswith(".mp4"))
|
||||
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?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue