diff --git a/src/centpkg/__main__.py b/src/centpkg/__main__.py index 549e5b2..c696c69 100644 --- a/src/centpkg/__main__.py +++ b/src/centpkg/__main__.py @@ -29,17 +29,22 @@ def main(): Centpkg main. """ - # Setup an argparser and parse the known commands to get the config file program_name = os.path.basename(sys.argv[0]) - # Modified ArgumentParser provides parameter "allow_abbrev=False" (which affects processing - # of commandline arguments with common prefix). Generaly it is available since python3.6. - - # This enables "allow_abbrev" for older python versions. - parser = pyrpkg.cli.ArgumentParser(add_help=False) + default_user_config_path = os.path.join( + os.path.expanduser('~'), '.config', 'rpkg', '%s.conf' % program_name) + + # Setup an argparser and parse the known commands to get the config file + + # - use the custom ArgumentParser class from pyrpkg.cli and disable + # argument abbreviation to ensure that --user will be not treated as + # --user-config + parser = pyrpkg.cli.ArgumentParser(add_help=False, allow_abbrev=False) parser.add_argument('-C', '--config', help='Specify a config file to use', - default=f'/etc/rpkg/%s.conf' % program_name) + default='/etc/rpkg/%s.conf' % program_name) + parser.add_argument('--user-config', help='Specify a user config file to use', + default=default_user_config_path) (args, other) = parser.parse_known_args() @@ -51,6 +56,7 @@ def main(): # Setup a configuration object and read config file data config = ConfigParser.SafeConfigParser() config.read(args.config) + config.read(args.user_config) client = centpkg.cli.centpkgClient(config, name=program_name) client.do_imports(site='centpkg')