diff --git a/docs/settings.rst b/docs/settings.rst index 9c73dc04..26f0a233 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -22,8 +22,8 @@ Settings are configured in the form of a Python module (a file). There is an available for reference. To see a list of current settings in your environment, including both default -and any customized values, run the following command (append a specific -setting name as an argument to see the value for that one setting):: +and any customized values, run the following command (append one or more +specific setting names as arguments to see values for those settings only):: pelican --print-settings diff --git a/pelican/__init__.py b/pelican/__init__.py index 0339681b..48dc6dff 100644 --- a/pelican/__init__.py +++ b/pelican/__init__.py @@ -320,11 +320,11 @@ def parse_arguments(): help='Relaunch pelican each time a modification occurs' ' on the content files.') - parser.add_argument('--print-settings', dest='print_settings', - action='append', nargs='?', metavar='SETTING_NAME', + parser.add_argument('--print-settings', dest='print_settings', nargs='*', + action='store', metavar='SETTING_NAME(S)', help='Print current configuration settings and exit. ' - 'Append a setting name as argument to see the value ' - 'for that specific setting only.') + 'Append one or more setting name arguments to see the ' + 'values for specific settings only.') parser.add_argument('--relative-urls', dest='relative_paths', action='store_true', @@ -535,18 +535,20 @@ def main(): try: 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 args.print_settings[0] is None: + if args.print_settings == []: pprint(settings) # An argument was given to --print-settings, so print that setting else: - try: - pprint(settings[args.print_settings[0]]) - except KeyError: - print("{} is not a recognized setting.".format( - args.print_settings[0])) - return 1 + for setting in args.print_settings: + try: + setting_value = settings[setting] + print("\n{}: ".format(setting)) + pprint(setting_value) + except KeyError: + print("\n{} is not a recognized setting.".format(setting)) + return 1 return 0 readers = Readers(settings)