feat: copy base configs to user configs
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
15
cic/config.py
Normal file
15
cic/config.py
Normal file
@@ -0,0 +1,15 @@
|
||||
import os
|
||||
import shutil
|
||||
|
||||
default_module_configs = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'config')
|
||||
|
||||
def ensure_base_configs(config_dir: str):
|
||||
"""
|
||||
Ensure that the base configs are present.
|
||||
"""
|
||||
if not os.path.exists(config_dir):
|
||||
os.makedirs(config_dir)
|
||||
for f in os.listdir(default_module_configs):
|
||||
if not os.path.exists(os.path.join(config_dir, f)):
|
||||
shutil.copytree(os.path.join(default_module_configs, f), os.path.join(config_dir, f))
|
||||
|
||||
@@ -13,6 +13,7 @@ import cic.cmd.show as cmd_show
|
||||
import cic.cmd.ext as cmd_ext
|
||||
import cic.cmd.export as cmd_export
|
||||
import cic.cmd.wizard as cmd_wizard
|
||||
from cic.config import ensure_base_configs
|
||||
|
||||
logging.basicConfig(level=logging.WARNING)
|
||||
logg = logging.getLogger()
|
||||
@@ -21,6 +22,7 @@ script_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
data_dir = os.path.join(script_dir, '..', 'data')
|
||||
base_config_dir = os.path.join(data_dir, 'config')
|
||||
schema_dir = os.path.join(script_dir, '..', 'schema')
|
||||
user_config_dir = os.path.join(os.path.expanduser("~"), ".config", "cic", "cli", "config")
|
||||
|
||||
arg_flags = chainlib.cli.argflag_std_read | chainlib.cli.Flag.SEQ
|
||||
argparser = chainlib.cli.ArgumentParser(
|
||||
@@ -62,6 +64,7 @@ cmd_mod = importlib.import_module(modname)
|
||||
extra_args = {
|
||||
'p': 'RPC_PROVIDER',
|
||||
}
|
||||
ensure_base_configs(user_config_dir)
|
||||
|
||||
config = chainlib.cli.Config.from_args(args, arg_flags=arg_flags, base_config_dir=base_config_dir, extra_args=extra_args)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user