diff --git a/.bluto/bluto.ini b/.bluto/bluto.ini index 949c162..7d1352a 100644 --- a/.bluto/bluto.ini +++ b/.bluto/bluto.ini @@ -15,4 +15,4 @@ url = https://gitlab.com/chaintools/chainlib url=https://holbrook.no [license] -WTFPL=2 +GPL=3+ diff --git a/chainlib/cli/arg.py b/chainlib/cli/arg.py index 9658b43..e3337be 100644 --- a/chainlib/cli/arg.py +++ b/chainlib/cli/arg.py @@ -144,7 +144,7 @@ class ArgumentParser(argparse.ArgumentParser): if arg_flags & Flag.CONFIG: self.add_argument('-c', '--config', type=str, default=env.get('CONFINI_DIR'), help='Configuration directory') self.add_argument('-n', '--namespace', type=str, help='Configuration namespace') - self.add_argument('--dumpconfig', action='store_true', help='Output configuration and quit. Use with --raw to omit values and output schema only.') + self.add_argument('--dumpconfig', type=str, choices=['env', 'ini'], help='Output configuration and quit. Use with --raw to omit values and output schema only.') if arg_flags & Flag.WAIT: self.add_argument('-w', action='store_true', help='Wait for the last transaction to be confirmed') self.add_argument('-ww', action='store_true', help='Wait for every transaction to be confirmed') diff --git a/chainlib/cli/config.py b/chainlib/cli/config.py index 6fdbc18..21ef81f 100644 --- a/chainlib/cli/config.py +++ b/chainlib/cli/config.py @@ -239,18 +239,26 @@ class Config(confini.Config): logg.debug('added {} to {}'.format(r, v)) if getattr(args, 'dumpconfig', None): - config_keys = config.all() - with_values = not config.get('_RAW') - for k in config_keys: - if k[0] == '_': - continue - s = k + '=' - if with_values: - v = config.get(k) - if v != None: - s += str(v) - s += '\n' - dump_writer.write(s) + if args.dumpconfig == 'ini': + from confini.export import ConfigExporter + exporter = ConfigExporter(config, target=sys.stdout, doc=False) + exporter.export(exclude_sections=[config]) + elif args.dumpconfig == 'env': + from confini.env import export_env + export_env(config) + +# config_keys = config.all() +# with_values = not config.get('_RAW') +# for k in config_keys: +# if k[0] == '_': +# continue +# s = k + '=' +# if with_values: +# v = config.get(k) +# if v != None: +# s += str(v) +# s += '\n' +# dump_writer.write(s) sys.exit(0) if load_callback != None: diff --git a/setup.cfg b/setup.cfg index 66600b4..12e1b06 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,7 +6,7 @@ name=chainlib license=WTFPL2 author_email=dev@holbrook.no description=Generic blockchain access library and tooling -version=0.0.10 +version=0.0.11 url=https://gitlab.com/chaintools/chainlib author=Louis Holbrook