Add global --plus-config
command arg
can now omit `--config` to get "normal" config, and use `--plus-config` to add some tweaks
This commit is contained in:
parent
424daaf89c
commit
25a3c9c2c9
|
@ -201,6 +201,8 @@ Usage: {0.name} [options] <command> [command-options]
|
|||
Options:
|
||||
-c PATH, --config=PATH
|
||||
Config path (may be specified more than once)
|
||||
--plus-config=PATH
|
||||
Extra config to load *in addition to* the normal config
|
||||
-n, --no-init Do not read any config files
|
||||
-P, --progress Show progress indicators (where relevant)
|
||||
-R, --runas Optional username to impersonate when running command
|
||||
|
@ -225,6 +227,9 @@ Commands:\n""".format(self))
|
|||
|
||||
parser.add_argument('-c', '--config', action='append', dest='config_paths',
|
||||
metavar='PATH')
|
||||
parser.add_argument('--plus-config', action='append',
|
||||
dest='plus_config_paths', metavar='PATH',
|
||||
help="Extra config to load *in addition to* the normal config")
|
||||
|
||||
# TODO: i think these aren't really being used in practice..?
|
||||
parser.add_argument('-n', '--no-init', action='store_true', default=False)
|
||||
|
@ -302,7 +307,8 @@ Commands:\n""".format(self))
|
|||
|
||||
else: # otherwise we make a proper config, and maybe turn on versioning
|
||||
logging.basicConfig()
|
||||
self.config = make_config(args.config_paths, extend=args.extend_config, versioning=False)
|
||||
self.config = make_config(args.config_paths, plus_files=args.plus_config_paths,
|
||||
extend=args.extend_config, versioning=False)
|
||||
if args.versioning:
|
||||
configure_versioning(self.config, force=True)
|
||||
elif not args.no_versioning:
|
||||
|
|
|
@ -1537,11 +1537,28 @@ class ConfigExtension(object):
|
|||
"""
|
||||
|
||||
|
||||
def make_config(files=None, usedb=None, preferdb=None, env=None, winsvc=None, extend=True, versioning=None):
|
||||
def make_config(
|
||||
files=None,
|
||||
plus_files=None,
|
||||
usedb=None,
|
||||
preferdb=None,
|
||||
env=None,
|
||||
winsvc=None,
|
||||
extend=True,
|
||||
versioning=None):
|
||||
"""
|
||||
Returns a new config object, initialized with the given parameters and
|
||||
further modified by all registered config extensions.
|
||||
|
||||
:param files: Config path(s) to be loaded. If not specified, then some
|
||||
"default" behavior will be attempted. This will check for env var
|
||||
``RATTAIL_CONFIG_FILES`` or fallback to system default paths. Or
|
||||
you can override all that by specifying some path(s) here.
|
||||
|
||||
:param plus_files: Additional config path(s) to be loaded. You
|
||||
may specify a "config tweak" file here, and leave ``files``
|
||||
empty, to get "normal plus tweak" behavior.
|
||||
|
||||
:param versioning: Controls whether or not the versioning system is
|
||||
configured with the new config object. If ``True``, versioning will be
|
||||
configured. If ``False`` then it will not be configured. If ``None``
|
||||
|
@ -1570,6 +1587,11 @@ def make_config(files=None, usedb=None, preferdb=None, env=None, winsvc=None, ex
|
|||
elif isinstance(files, str):
|
||||
files = [files]
|
||||
|
||||
if plus_files:
|
||||
if isinstance(plus_files, str):
|
||||
plus_files = [plus_files]
|
||||
files += plus_files
|
||||
|
||||
# If making config for a Windows service, we must read the default config
|
||||
# file(s) first, and check it to see if there is an alternate config file
|
||||
# which should be considered the "root" file. Normally we specify the root
|
||||
|
|
Loading…
Reference in a new issue