forked from github/pelican
Support multiple --print-settings arguments
This commit is contained in:
parent
e81a284c39
commit
f130695bbf
2 changed files with 16 additions and 14 deletions
|
|
@ -22,8 +22,8 @@ Settings are configured in the form of a Python module (a file). There is an
|
||||||
available for reference.
|
available for reference.
|
||||||
|
|
||||||
To see a list of current settings in your environment, including both default
|
To see a list of current settings in your environment, including both default
|
||||||
and any customized values, run the following command (append a specific
|
and any customized values, run the following command (append one or more
|
||||||
setting name as an argument to see the value for that one setting)::
|
specific setting names as arguments to see values for those settings only)::
|
||||||
|
|
||||||
pelican --print-settings
|
pelican --print-settings
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -320,11 +320,11 @@ def parse_arguments():
|
||||||
help='Relaunch pelican each time a modification occurs'
|
help='Relaunch pelican each time a modification occurs'
|
||||||
' on the content files.')
|
' on the content files.')
|
||||||
|
|
||||||
parser.add_argument('--print-settings', dest='print_settings',
|
parser.add_argument('--print-settings', dest='print_settings', nargs='*',
|
||||||
action='append', nargs='?', metavar='SETTING_NAME',
|
action='store', metavar='SETTING_NAME(S)',
|
||||||
help='Print current configuration settings and exit. '
|
help='Print current configuration settings and exit. '
|
||||||
'Append a setting name as argument to see the value '
|
'Append one or more setting name arguments to see the '
|
||||||
'for that specific setting only.')
|
'values for specific settings only.')
|
||||||
|
|
||||||
parser.add_argument('--relative-urls', dest='relative_paths',
|
parser.add_argument('--relative-urls', dest='relative_paths',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
|
|
@ -535,18 +535,20 @@ def main():
|
||||||
try:
|
try:
|
||||||
pelican, settings = get_instance(args)
|
pelican, settings = get_instance(args)
|
||||||
|
|
||||||
if args.print_settings:
|
if args.print_settings != None:
|
||||||
# If no argument was given to --print-settings, print all settings
|
# If no argument was given to --print-settings, print all settings
|
||||||
if args.print_settings[0] is None:
|
if args.print_settings == []:
|
||||||
pprint(settings)
|
pprint(settings)
|
||||||
# An argument was given to --print-settings, so print that setting
|
# An argument was given to --print-settings, so print that setting
|
||||||
else:
|
else:
|
||||||
try:
|
for setting in args.print_settings:
|
||||||
pprint(settings[args.print_settings[0]])
|
try:
|
||||||
except KeyError:
|
setting_value = settings[setting]
|
||||||
print("{} is not a recognized setting.".format(
|
print("\n{}: ".format(setting))
|
||||||
args.print_settings[0]))
|
pprint(setting_value)
|
||||||
return 1
|
except KeyError:
|
||||||
|
print("\n{} is not a recognized setting.".format(setting))
|
||||||
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
readers = Readers(settings)
|
readers = Readers(settings)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue