def METHOD_NAME(opts, parser, extra_arg_groups=None):
    from rez.config import config
    from rez.package_cache import PackageCache
    from rez.utils.formatting import print_colored_columns
    from rez.utils import colorize
    statuses = {
        PackageCache.VARIANT_FOUND: ("cached", colorize.local, 0),
        PackageCache.VARIANT_COPYING: ("copying", colorize.warning, 1),
        PackageCache.VARIANT_COPY_STALLED: ("stalled", colorize.error, 2),
        PackageCache.VARIANT_PENDING: ("pending", colorize.inactive, 3)
    }
    cachepath = opts.DIR or config.cache_packages_path
    if not cachepath:
        parser.error(
            "DIR must be specified, as there is no configured "
            "'cache_packages_path'"
        )
    pkgcache = PackageCache(cachepath)
    if opts.daemon:
        pkgcache.run_daemon()
    elif opts.add_variants:
        for uri in opts.add_variants:
            add_variant(pkgcache, uri, opts)
    elif opts.remove_variants:
        for uri in opts.remove_variants:
            remove_variant(pkgcache, uri, opts)
    elif opts.clean:
        pkgcache.clean()
    elif opts.logs:
        view_logs(pkgcache, opts)
    else:
        tty = sys.stdout.isatty()
        # just print current state of package cache
        if tty:
            print("Package cache at %s:\n" % cachepath)
        def _sort(entry):
            variant, _, status = entry
            return (statuses[status][-1], variant.name)
        entries = sorted(pkgcache.get_variants(), key=_sort)
        if not entries:
            print("No cached packages.", file=sys.stderr)
            sys.exit(0)
        rows = []
        if tty:
            rows.append([c.replace('_', ' ') for c in opts.columns] + [None])  # headers
            rows.append([('-' * len(c)) for c in opts.columns] + [None])  # underlines
        for variant, rootpath, status in entries:
            status_str, color, _ = statuses[status]
            row = []
            for c in opts.columns:
                if c == "status":
                    row.append(status_str)
                elif c == "package":
                    row.append(variant.parent.qualified_name)
                elif c == "variant_uri":
                    row.append(variant.uri)
                elif c == "orig_path":
                    row.append(variant.root)
                else:  # cached_path
                    row.append(rootpath or '-')
            row.append(color)
            rows.append(row)
        pr = colorize.Printer()
        print_colored_columns(pr, rows)