25 lines
789 B
Python
25 lines
789 B
Python
|
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)
|