Add config init, currently broken due to docker wrapping
This commit is contained in:
parent
dad46d3655
commit
18c689f897
2 changed files with 24 additions and 2 deletions
22
config.py
22
config.py
|
@ -260,6 +260,15 @@ class ConfigStateHolder:
|
|||
self._profile_cache = resolve_profile(name, self.file['profiles'], resolved=self._profile_cache)
|
||||
return self._profile_cache[name]
|
||||
|
||||
def dump(self) -> str:
|
||||
dump_toml(self.file)
|
||||
|
||||
def write(self, path=None):
|
||||
if path is None:
|
||||
path = self.runtime['config_file']
|
||||
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||
dump_file(path, self.file)
|
||||
|
||||
|
||||
config = ConfigStateHolder(file_conf_base=CONFIG_DEFAULTS)
|
||||
|
||||
|
@ -270,6 +279,19 @@ config_option = click.option(
|
|||
help='Override path to config file',
|
||||
)
|
||||
|
||||
|
||||
@click.group(name='config')
|
||||
def cmd_config():
|
||||
pass
|
||||
|
||||
|
||||
@cmd_config.command(name='init')
|
||||
def cmd_init():
|
||||
"""Initialize the config file"""
|
||||
# TODO
|
||||
config.write()
|
||||
|
||||
|
||||
# temporary demo
|
||||
if __name__ == '__main__':
|
||||
print('vanilla:')
|
||||
|
|
4
main.py
4
main.py
|
@ -8,7 +8,7 @@ from forwarding import cmd_forwarding
|
|||
from telnet import cmd_telnet
|
||||
from logger import logging, setup_logging, verbose_option
|
||||
import click
|
||||
from config import config, config_option
|
||||
from config import config, config_option, cmd_config
|
||||
from wrapper import enforce_wrap, nowrapper_option
|
||||
from traceback import format_exc as get_trace
|
||||
|
||||
|
@ -32,7 +32,7 @@ def main():
|
|||
logging.fatal(get_trace())
|
||||
exit(1)
|
||||
|
||||
|
||||
cli.add_command(cmd_config)
|
||||
cli.add_command(cmd_cache)
|
||||
cli.add_command(cmd_packages)
|
||||
cli.add_command(cmd_image)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue