Commit 3f17472b authored by Seblu's avatar Seblu
Browse files

Reorganize option parser

parent 748043b0
Loading
Loading
Loading
Loading
+19 −13
Original line number Original line Diff line number Diff line
@@ -321,10 +321,7 @@ def parse_argv():
    '''Parse command line arguments'''
    '''Parse command line arguments'''
    local_arch = uname().machine
    local_arch = uname().machine
    p_main = ArgumentParser()
    p_main = ArgumentParser()
    p_main.add_argument("--version", action="version",
    # update index options
                        version="%(prog)s version " + VERSION)
    p_main.add_argument("--debug", action="store_true",
                        help="debug mode")
    g_update = p_main.add_mutually_exclusive_group()
    g_update = p_main.add_mutually_exclusive_group()
    g_update.add_argument("-u", "--force-update",
    g_update.add_argument("-u", "--force-update",
        action="store_const", dest="update", const=2, default=1,
        action="store_const", dest="update", const=2, default=1,
@@ -332,19 +329,28 @@ def parse_argv():
    g_update.add_argument("-U", "--no-update",
    g_update.add_argument("-U", "--no-update",
        action="store_const", dest="update", const=0,
        action="store_const", dest="update", const=0,
        help="disable index update")
        help="disable index update")
    p_main.add_argument("-l", "--list", action="store_const", dest="mode", const="list",
    # action mode options
        help="only list matching packages")
    g_action = p_main.add_mutually_exclusive_group()
    p_main.add_argument("-g", "--get", action="store_const", dest="mode", const="get",
    g_action.add_argument("-g", "--get", action="store_const", dest="mode",
        help="get matching packages (default)")
        const="get", help="get matching packages (default mode)")
    p_main.add_argument("-i", "--install", action="store_const", dest="mode", const="install",
    g_action.add_argument("-l", "--list", action="store_const", dest="mode",
        help="install matching packages")
        const="list", help="only list matching packages")
    p_main.add_argument("-a", "--arch", nargs="*", default=[local_arch, "any"],
    g_action.add_argument("-i", "--install", action="store_const", dest="mode",
        help="filter by architectures (default is %s and any. empty means all)" % local_arch)
        const="install", help="install matching packages")
    # common options
    p_main.add_argument("-A", "--arch", nargs="*", default=[local_arch, "any"],
        help="filter by architectures (default: %s and any. empty means all)" % local_arch)
    p_main.add_argument("-v", "--verbose", action="store_true",
    p_main.add_argument("-v", "--verbose", action="store_true",
        help="display more information")
        help="display more information")
    p_main.add_argument("--url", help="archive URL, default: %s" % ARCHIVE_URL,
    p_main.add_argument("--url", help="archive URL, default: %s" % ARCHIVE_URL,
        default=environ.get("ARCHIVE_URL", ARCHIVE_URL))
        default=environ.get("ARCHIVE_URL", ARCHIVE_URL))
    p_main.add_argument("-t", "--timeout", default=10, help="connection timeout (10s)")
    p_main.add_argument("-t", "--timeout", default=10,
        help="connection timeout (default: 10s)")
    p_main.add_argument("--version", action="version",
                        version="%(prog)s version " + VERSION)
    p_main.add_argument("--debug", action="store_true",
                        help="debug mode")
    # positional args
    p_main.add_argument("package",
    p_main.add_argument("package",
        help="regex to match a package name")
        help="regex to match a package name")
    p_main.add_argument("version", nargs="?",
    p_main.add_argument("version", nargs="?",