Add a configure command for initial wad setup. Reshuffle a couple things that depend on it.
This commit is contained in:
parent
673e649e87
commit
5881c94c11
4 changed files with 34 additions and 10 deletions
24
dcc/configure.py
Normal file
24
dcc/configure.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
import dcc.config
|
||||
import tomlkit
|
||||
from tomlkit.toml_file import TOMLFile
|
||||
|
||||
class Configure(dcc.config.Base):
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
parser.add_argument("wad")
|
||||
parser.add_argument("complevel")
|
||||
parser.add_argument("--iwad")
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
new_config = self.pwads.joinpath(parsed_args.wad).joinpath(self.config_name)
|
||||
if new_config.exists():
|
||||
raise Exception("Config %s already exists.".format(new_config))
|
||||
|
||||
doc = tomlkit.document()
|
||||
doc.add("complevel", parsed_args.complevel)
|
||||
if parsed_args.iwad is not None:
|
||||
doc.add("iwad", parsed_args.iwad)
|
||||
|
||||
f = TOMLFile(new_config)
|
||||
f.write(doc)
|
Loading…
Add table
Add a link
Reference in a new issue