get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/134517/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 134517,
    "url": "http://patches.dpdk.org/api/patches/134517/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20231121122651.7078-1-fengchengwen@huawei.com/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20231121122651.7078-1-fengchengwen@huawei.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20231121122651.7078-1-fengchengwen@huawei.com",
    "date": "2023-11-21T12:26:51",
    "name": "[24.03,RFC] argparse: add argparse library",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "970b885cbadaa5e94c8db0f0f17dfadfd02d5fcd",
    "submitter": {
        "id": 2146,
        "url": "http://patches.dpdk.org/api/people/2146/?format=api",
        "name": "fengchengwen",
        "email": "fengchengwen@huawei.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20231121122651.7078-1-fengchengwen@huawei.com/mbox/",
    "series": [
        {
            "id": 30348,
            "url": "http://patches.dpdk.org/api/series/30348/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=30348",
            "date": "2023-11-21T12:26:51",
            "name": "[24.03,RFC] argparse: add argparse library",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/30348/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/134517/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/134517/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id C01744338E;\n\tTue, 21 Nov 2023 13:29:47 +0100 (CET)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id AC71042EA6;\n\tTue, 21 Nov 2023 13:29:47 +0100 (CET)",
            "from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187])\n by mails.dpdk.org (Postfix) with ESMTP id 52E8B42E9D\n for <dev@dpdk.org>; Tue, 21 Nov 2023 13:29:45 +0100 (CET)",
            "from dggpeml100024.china.huawei.com (unknown [172.30.72.53])\n by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SZNwc4lQgzvR1n;\n Tue, 21 Nov 2023 20:29:20 +0800 (CST)",
            "from localhost.localdomain (10.50.165.33) by\n dggpeml100024.china.huawei.com (7.185.36.115) with Microsoft SMTP Server\n (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id\n 15.1.2507.35; Tue, 21 Nov 2023 20:29:43 +0800"
        ],
        "From": "Chengwen Feng <fengchengwen@huawei.com>",
        "To": "<dev@dpdk.org>, <thomas@monjalon.net>, <ferruh.yigit@amd.com>",
        "Subject": "[24.03 RFC] argparse: add argparse library",
        "Date": "Tue, 21 Nov 2023 12:26:51 +0000",
        "Message-ID": "<20231121122651.7078-1-fengchengwen@huawei.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain",
        "X-Originating-IP": "[10.50.165.33]",
        "X-ClientProxiedBy": "dggems706-chm.china.huawei.com (10.3.19.183) To\n dggpeml100024.china.huawei.com (7.185.36.115)",
        "X-CFilter-Loop": "Reflected",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org"
    },
    "content": "Introduce argparse library (which was inspired by the thread [1]),\ncompared with getopt, the argparse has following advantages:\n1) Set the help information when defining parameters.\n2) Support positional parameters.\n\nThe parameters parsing according following:\n1) positional: use callback to parse (passed the long-name as the key\n   for callback).\n2) optional:\n   In addition to callback to parse, but also support:\n2.1) no-val: support set default value to saver.\n2.2) has-val: support set value to saver, the value must be conform\n              RTE_ARGPARSE_ARG_VAL_xxx.\n2.3) opt-val: if current without value then treat as no-val, else could\n              treat as has-val.\n\nExamples: (take dmafwd as example):\n1) If parse with callback:\n\tstatic int\n\tfunc(const char *key, const char *value, const char *opaque)\n\t{\n\t\tif (!strcmp(\"--mac-updating\", key)) {\n\t\t\tmac_updating = 1;\n\t\t} else if (!strcmp(\"--no-mac-updating\", key)) {\n\t\t\tmac_updating = 0;\n\t\t} else if (!strcmp(\"--portmask\", key)) {\n\t\t\tdma_enabled_port_mask = dma_parse_portmask(optarg);\n\t\t\tif (dma_enabled_port_mask & ~default_port_mask ||\n\t\t\t\t\t\tdma_enabled_port_mask <= 0) {\n\t\t\t\t...\n\t\t\t}\n\t\t} else {\n\t\t\t...\n\t\t}\n\t}\n\n\tstatic int\n\tdma_parse_args(int argc, char **argv, unsigned int nb_ports)\n\t{\n\t\tstatic struct rte_argparse opts[] = {\n\t\t\t.prog = \"dma\",\n\t\t\t.usage = NULL,\n\t\t\t.descriptor = \"dma and nic fwd example\",\n\t\t\t.epilog = NULL,\n\t\t\t.exit_on_error = true,\n\t\t\t.opt = {\n\t\t\t\t{ \"--mac-updating\", NULL, \"Enable MAC addresses updating\", func, 0, NULL, NULL, RTE_ARGPARSE_ARG_NO_VAL },\n\t\t\t\t{ \"--no-mac-updating\", NULL, \"disable MAC addresses updating\", func, 0, NULL, NULL, RTE_ARGPARSE_ARG_NO_VAL },\n\t\t\t\t{ \"--portmask\", \"-p\", \"hexadecimal bitmask of ports to configure\", func, 0, NULL, NULL, RTE_ARGPARSE_ARG_HAS_VAL },\n\t\t\t\t{ NULL, NULL, NULL, NULL, 0, NULL, NULL, 0}\n\t\t\t}\n\t\t};\n\t\treturn rte_argparse_parse(opts, argc, argv);\n\t}\n\n2) If parse with value:\n\tstatic int\n\tdma_parse_args(int argc, char **argv, unsigned int nb_ports)\n\t{\n\t\tstatic struct rte_argparse opts[] = {\n\t\t\t.prog = \"dma\",\n\t\t\t.usage = NULL,\n\t\t\t.descriptor = \"dma and nic fwd example\",\n\t\t\t.epilog = NULL,\n\t\t\t.exit_on_error = true,\n\t\t\t.opt = {\n\t\t\t\t{ \"--mac-updating\", NULL, \"Enable MAC addresses updating\", NULL, 0, &mac_updating, (void *)1, RTE_ARGPARSE_ARG_NO_VAL },\n\t\t\t\t{ \"--no-mac-updating\", NULL, \"disable MAC addresses updating\", NULL, 0, &mac_updating, (void *)0, RTE_ARGPARSE_ARG_NO_VAL },\n\t\t\t\t{ \"--portmask\", \"-p\", \"hexadecimal bitmask of ports to configure\", NULL, 0, &dma_enabled_port_mask, NULL, RTE_ARGPARSE_ARG_HAS_VAL },\n\t\t\t\t{ NULL, NULL, NULL, NULL, 0, NULL, NULL, 0}\n\t\t\t}\n\t\t};\n\t\tint ret;\n\t\tret = rte_argparse_parse(opts, argc, argv);\n\t\tif (ret != 0)\n\t\t\treturn ret;\n\t\tif (dma_enabled_port_mask & ~default_port_mask ||\n\t\t\t\t\tdma_enabled_port_mask <= 0) {\n\t\t\t...\n\t\t}\n\t}\n\n3) Also could mix parse with func and with value.\n\n[1] https://patchwork.dpdk.org/project/dpdk/patch/20231105054539.22303-2-fengchengwen@huawei.com/\n\nSigned-off-by: Chengwen Feng <fengchengwen@huawei.com>\n---\n lib/argparse/meson.build    |   6 ++\n lib/argparse/rte_argparse.h | 139 ++++++++++++++++++++++++++++++++++++\n lib/argparse/version.map    |   7 ++\n lib/meson.build             |   1 +\n 4 files changed, 153 insertions(+)\n create mode 100644 lib/argparse/meson.build\n create mode 100644 lib/argparse/rte_argparse.h\n create mode 100644 lib/argparse/version.map",
    "diff": "diff --git a/lib/argparse/meson.build b/lib/argparse/meson.build\nnew file mode 100644\nindex 0000000000..ac4a883b8d\n--- /dev/null\n+++ b/lib/argparse/meson.build\n@@ -0,0 +1,6 @@\n+# SPDX-License-Identifier: BSD-3-Clause\n+# Copyright(c) 2023 HiSilicon Limited.\n+\n+headers = files('rte_argparse.h')\n+\n+deps += ['kvargs']\ndiff --git a/lib/argparse/rte_argparse.h b/lib/argparse/rte_argparse.h\nnew file mode 100644\nindex 0000000000..21157a9436\n--- /dev/null\n+++ b/lib/argparse/rte_argparse.h\n@@ -0,0 +1,139 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2023 HiSilicon Limited\n+ */\n+\n+#ifndef RTE_ARGPARSE_H\n+#define RTE_ARGPARSE_H\n+\n+/**\n+ * @file rte_argparse.h\n+ *\n+ * This API provides argparse function.\n+ *\n+ * Compare with getopt, the argparse has following advantages:\n+ * 1) Set the help information when defining parameters.\n+ * 2) Support positional parameters.\n+ *\n+ * The parameters parsing according following:\n+ * 1) positional: use callback to parse (passed the long-name as the key for\n+ *    callback).\n+ * 2) optional:\n+ *    In addition to callback to parse, but also support:\n+ *    2.1) no-val: support set default value to saver.\n+ *    2.2) has-val: support set value to saver, the value must be conform\n+ *                  RTE_ARGPARSE_ARG_VAL_xxx.\n+ *    2.3) opt-val: if current without value then treat as no-val, else could\n+ *                  treat as has-val.\n+ *\n+ */\n+\n+#include <stdint.h>\n+\n+#include <rte_kvargs.h>\n+\n+#ifdef __cplusplus\n+extern \"C\" {\n+#endif\n+\n+enum rte_argparse_arg_flags {\n+\t/**\n+\t * Bit0-1 represent whether has value\n+\t */\n+\tRTE_ARGPARSE_ARG_NO_VAL = 1u << 0, /**< The arg has no value. */\n+\tRTE_ARGPARSE_ARG_HAS_VAL = 2u << 0, /**< The arg has value. */\n+\tRTE_ARGPARSE_ARG_OPT_VAL = 3u << 0, /**< The arg has optional value. */\n+\n+\t/**\n+\t * Bit2-4 represent the value type\n+\t */\n+\tRTE_ARGPARSE_ARG_VAL_INT = 1u << 2, /**< The arg's value is int type. */\n+\tRTE_ARGPARSE_ARG_VAL_FLOAT = 2u << 2, /**< The arg's value is float type. */\n+\tRTE_ARGPARSE_ARG_VAL_BOOL = 3u << 2, /**< The arg's value is bool type. */\n+\tRTE_ARGPARSE_ARG_VAL_STRING = 4u << 2, /**< The arg's value is string type. */\n+};\n+\n+/**\n+ * A structure used to hold opt config.\n+ */\n+struct rte_argparse_arg {\n+\t/**\n+\t * The long name of arg:\n+\t *   1) If the arg is optional, it must start with '--',\n+\t *   2) If it is a positional arg, it must not start with '-'.\n+\t * Note: only one '-' will treat as error.\n+\t */\n+\tconst char *long_name;\n+\t/**\n+\t * The short name of arg:\n+\t *   1) This field could be set only if long_name is optional, and must\n+\t *      start with only one '-' and one letter,\n+\t *   2) Other case it should be set NULL.\n+\t */\n+\tconst char *short_name;\n+\t/** The help info of arg. */\n+\tconst char *help;\n+\n+\t/*\n+\t * Parse the arg's callback, it will be used to parse the arg if\n+\t * it is not NULL.\n+\t */\n+\targ_handler_t callback;\n+\t/** The opaque which used to invoke callback */\n+\tvoid *opaque;\n+\n+\t/*\n+\t * The saver for the arg. If not NULL, set value to default_val or\n+\t * parse from input.\n+\t * Note: the flags of the arg must be RTE_ARGPARSE_VAL_* if this value\n+\t * is not NULL.\n+\t */\n+\tvoid *saver;\n+\t/*\n+\t * Default value for the arg, cover following case:\n+\t *   1) The arg don't require value, the saver will set to default_val\n+\t *      when option found.\n+\t *   2) The arg has option value but don't take value this time, the\n+\t *      saver will set to default_val when option found.\n+\t */\n+\tvoid *default_val;\n+\n+\t/** @see rte_argparse_arg_flags. */\n+\tuint32_t flags;\n+};\n+\n+/**\n+ * A structure used to hold argparse basic info.\n+ */\n+struct rte_argparse {\n+\tconst char *prog;       /**< Program name */\n+\tconst char *usage;      /**< How to use the program */\n+\tconst char *descriptor; /**< Explain what the program does */\n+\tconst char *epilog;     /**< Text at the bottom of help */\n+\tbool exit_on_error;     /**< Whether exit when error */\n+\tstruct rte_argparse_arg opt[]; /**< */\n+};\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice.\n+ *\n+ * Parse parameters\n+ *\n+ * @param self\n+ *   Parser handler.\n+ * @param argc\n+ *   Parameters count\n+ * @param argv\n+ *   Array of parameters points.\n+ *\n+ * @return\n+ *   0 on success. Otherwise negative value is returned.\n+ */\n+__rte_experimental\n+int rte_argparse_parse(struct rte_argparse *self, int argc, char **argv);\n+\n+#ifdef __cplusplus\n+}\n+#endif\n+\n+#endif /* RTE_ARGPARSE_H */\ndiff --git a/lib/argparse/version.map b/lib/argparse/version.map\nnew file mode 100644\nindex 0000000000..36b0902167\n--- /dev/null\n+++ b/lib/argparse/version.map\n@@ -0,0 +1,7 @@\n+EXPERIMENTAL  {\n+\tglobal:\n+\n+\trte_argparse_parse;\n+\n+\tlocal: *;\n+};\ndiff --git a/lib/meson.build b/lib/meson.build\nindex 6c143ce5a6..cdd2d3c536 100644\n--- a/lib/meson.build\n+++ b/lib/meson.build\n@@ -11,6 +11,7 @@\n libraries = [\n         'log',\n         'kvargs', # eal depends on kvargs\n+        'argparse',\n         'telemetry', # basic info querying\n         'eal', # everything depends on eal\n         'ring',\n",
    "prefixes": [
        "24.03",
        "RFC"
    ]
}