Build ArgumentParser content

def _get_parser():
    """ Build ArgumentParser content"""

    usage_string = ("%(prog)s [options]\n\n"
                    "Some examples:\n\n"
                    "enable dlm plugin only and collect dlm lockdumps:\n"
                    "  # sosreport -o dlm -k dlm.lockdump\n\n"
                    "disable memory and samba plugins, turn off rpm "
                    "-Va collection:\n"
                    "  # sosreport -n memory,samba -k rpm.rpmva=off")

    parser = ArgumentParser(usage=usage_string)
    parser.register('action', 'extend', SosListOption)
    parser.add_argument("-a", "--alloptions", action="store_true",
                        dest="alloptions", default=False,
                        help="enable all options for loaded plugins")
    parser.add_argument("--all-logs", action="store_true",
                        dest="all_logs", default=False,
                        help="collect all available logs regardless "
                             "of size")
    parser.add_argument("--batch", action="store_true",
                        dest="batch", default=False,
                        help="batch mode - do not prompt interactively")
    parser.add_argument("--build", action="store_true",
                        dest="build", default=False,
                        help="preserve the temporary directory and do not "
                             "package results")
    parser.add_argument("--case-id", action="store",
                        dest="case_id",
                        help="specify case identifier")
    parser.add_argument("-c", "--chroot", action="store", dest="chroot",
                        help="chroot executed commands to SYSROOT "
                             "[auto, always, never] (default=auto)",
                        default=_arg_defaults["chroot"])
    parser.add_argument("--config-file", type=str, action="store",
                        dest="config_file", default="/etc/sos.conf",
                        help="specify alternate configuration file")
    parser.add_argument("--debug", action="store_true", dest="debug",
                        help="enable interactive debugging using the "
                             "python debugger")
    parser.add_argument("--desc", "--description", type=str, action="store",
                        help="Description for a new preset", default="")
    parser.add_argument("--dry-run", action="store_true",
                        help="Run plugins but do not collect data")
    parser.add_argument("--experimental", action="store_true",
                        dest="experimental", default=False,
                        help="enable experimental plugins")
    parser.add_argument("-e", "--enable-plugins", action="extend",
                        dest="enableplugins", type=str,
                        help="enable these plugins", default=[])
    parser.add_argument("-k", "--plugin-option", action="extend",
                        dest="plugopts", type=str,
                        help="plugin options in plugname.option=value "
                             "format (see -l)", default=[])
    parser.add_argument("--label", "--name", action="store", dest="label",
                        help="specify an additional report label")
    parser.add_argument("-l", "--list-plugins", action="store_true",
                        dest="list_plugins", default=False,
                        help="list plugins and available plugin options")
    parser.add_argument("--list-presets", action="store_true",
                        help="display a list of available presets")
    parser.add_argument("--list-profiles", action="store_true",
                        dest="list_profiles", default=False,
                        help="display a list of available profiles and "
                             "plugins that they include")
    parser.add_argument("--log-size", action="store", dest="log_size",
                        type=int, default=_arg_defaults["log_size"],
                        help="limit the size of collected logs (in MiB)")
    parser.add_argument("-n", "--skip-plugins", action="extend",
                        dest="noplugins", type=str,
                        help="disable these plugins", default=[])
    parser.add_argument("--no-report", action="store_true",
                        dest="noreport",
                        help="disable plaintext/HTML reporting", default=False)
    parser.add_argument("--note", type=str, action="store", default="",
                        help="Behaviour notes for new preset")
    parser.add_argument("-o", "--only-plugins", action="extend",
                        dest="onlyplugins", type=str,
                        help="enable these plugins only", default=[])
    parser.add_argument("--preset", action="store", type=str,
                        help="A preset identifier", default="auto")
    parser.add_argument("--plugin-timeout", default=None,
                        help="set a timeout for all plugins")
    parser.add_argument("-p", "--profile", action="extend",
                        dest="profiles", type=str, default=[],
                        help="enable plugins used by the given profiles")
    parser.add_argument("-q", "--quiet", action="store_true",
                        dest="quiet", default=False,
                        help="only print fatal errors")
    parser.add_argument("-s", "--sysroot", action="store", dest="sysroot",
                        help="system root directory path (default='/')",
                        default=None)
    parser.add_argument("--ticket-number", action="store",
                        dest="case_id",
                        help="specify ticket number")
    parser.add_argument("--tmp-dir", action="store",
                        dest="tmp_dir",
                        help="specify alternate temporary directory",
                        default=None)
    parser.add_argument("-v", "--verbose", action="count", dest="verbosity",
                        default=_arg_defaults["verbosity"],
                        help="increase verbosity"),
    parser.add_argument("--verify", action="store_true",
                        dest="verify", default=False,
                        help="perform data verification during collection")
    parser.add_argument("-z", "--compression-type", dest="compression_type",
                        default=_arg_defaults["compression_type"],
                        help="compression technology to use [auto, "
                             "gzip, bzip2, xz] (default=auto)")
    parser.add_argument("-t", "--threads", action="store", dest="threads",
                        help="specify number of concurrent plugins to run"
                        " (default=4)", default=4, type=int)

    # Group to make add/del preset exclusive
    preset_grp = parser.add_mutually_exclusive_group()
    preset_grp.add_argument("--add-preset", type=str, action="store",
                            help="Add a new named command line preset")
    preset_grp.add_argument("--del-preset", type=str, action="store",
                            help="Delete the named command line preset")

    # Group to make tarball encryption (via GPG/password) exclusive
    encrypt_grp = parser.add_mutually_exclusive_group()
    encrypt_grp.add_argument("--encrypt-key",
                             help="Encrypt the final archive using a GPG "
                                  "key-pair")
    encrypt_grp.add_argument("--encrypt-pass",
                             help="Encrypt the final archive using a password")

    return parser