chainlib

Generic blockchain access library and tooling
Log | Files | Refs | README | LICENSE

commit 32f023a67e390c7fdb858ff7d1c3ea5cbc756e35
parent 27c2b5f90f054a720ac70199cc2a345c24fd9f90
Author: lash <dev@holbrook.no>
Date:   Thu,  3 Nov 2022 21:11:14 +0000

Add config key for first positional argument

Diffstat:
MCHANGELOG | 1+
Mchainlib/cli/arg.py | 1-
Mchainlib/cli/config.py | 8+++++++-
3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG @@ -2,6 +2,7 @@ * Reinstate stdin_arg * Add -r alias to --raw * Remove old dead arg selector code + * Add universal config key for first positional argument - 0.3.2 * Add missing "confirmed" arg to nonce oracle, expected by chainlib-eth test - 0.3.1 diff --git a/chainlib/cli/arg.py b/chainlib/cli/arg.py @@ -90,7 +90,6 @@ class Arg(BaseArg): def __init__(self, flags): super(Arg, self).__init__(flags) - self.add_long('no-logs', 'verbose', typ=bool, help='Turn off all logging') self.add('v', 'verbose', typ=bool, help='Be verbose') self.add('vv', 'verbose', check=False, typ=bool, help='Be more verbose') diff --git a/chainlib/cli/config.py b/chainlib/cli/config.py @@ -48,7 +48,7 @@ class Config(confini.Config): return super(Config, self).add_override_dir(v) -def process_config(config, arg, args, flags): +def process_config(config, arg, args, flags, positional_name=None): if arg.match('env', flags): config.set_env_prefix(getattr(args, 'env_prefix')) @@ -133,4 +133,10 @@ def process_config(config, arg, args, flags): config.add(getattr(args, 'rpc_auth'), 'RPC_AUTH') config.add(getattr(args, 'rpc_credentials'), 'RPC_CREDENTIALS') + if positional_name != None: + config.add(None, '_POSARG', False) + pos_arg = getattr(args, positional_name) + if len(pos_arg) > 0: + config.add(pos_arg[0], '_POSARG', True) + return config