23 lines
719 B
Python
23 lines
719 B
Python
import dcc.doom_base
|
|
import tomlkit.toml_file
|
|
|
|
|
|
class Configure(dcc.doom_base.Wad):
|
|
def get_parser(self, prog_name):
|
|
parser = super().get_parser(prog_name)
|
|
parser.add_argument("complevel")
|
|
parser.add_argument("--iwad")
|
|
return parser
|
|
|
|
def take_action(self, parsed_args):
|
|
new_config = self.pwad_path.joinpath(self.config_name)
|
|
if new_config.exists():
|
|
raise Exception(f"Config {new_config} already exists.")
|
|
|
|
doc = tomlkit.document()
|
|
doc.add("complevel", parsed_args.complevel)
|
|
if parsed_args.iwad is not None:
|
|
doc.add("iwad", parsed_args.iwad)
|
|
|
|
f = tomlkit.toml_file.TOMLFile(new_config)
|
|
f.write(doc)
|