Show a patch.

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

{
    "id": 12821,
    "url": "https://patchwork.libcamera.org/api/patches/12821/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/12821/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20210707021941.20804-9-laurent.pinchart@ideasonboard.com>",
    "date": "2021-07-07T02:19:19",
    "name": "[libcamera-devel,08/30] cam: options: Move key string left in usage() for key-value parser",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "fd38a00fa86c3eeaffc6525490aba07141e8bbb3",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/12821/mbox/",
    "series": [
        {
            "id": 2213,
            "url": "https://patchwork.libcamera.org/api/series/2213/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2213",
            "date": "2021-07-07T02:19:12",
            "name": "Multi-camera support in the cam application",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/2213/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/12821/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/12821/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>",
        "X-Original-To": "parsemail@patchwork.libcamera.org",
        "Delivered-To": "parsemail@patchwork.libcamera.org",
        "Received": [
            "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 93B71BD794\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  7 Jul 2021 02:20:43 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0ED1868535;\n\tWed,  7 Jul 2021 04:20:39 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6257468514\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  7 Jul 2021 04:20:34 +0200 (CEST)",
            "from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id F12552E4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  7 Jul 2021 04:20:33 +0200 (CEST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"DLpAuzg6\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1625624434;\n\tbh=XBJbTOiN/TPJcouW5fjfxlnCeo3qBdDvjqSHmEsG6S0=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=DLpAuzg6QRzZ5uIWyDfeyMXoldc7ClUtzf6DUb1fzKadeSxwLNODR6iHAYocBTbbj\n\t7IEuz+KC1tjlWTJNVcktLmbpSojmhvpaGrAASliXaKAa8thoSLjD49KHrUA9BzOo/p\n\tFHBOwSZu3de790r94gecboDSJaiLuWYXaAxMzElc=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed,  7 Jul 2021 05:19:19 +0300",
        "Message-Id": "<20210707021941.20804-9-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.31.1",
        "In-Reply-To": "<20210707021941.20804-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20210707021941.20804-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 08/30] cam: options: Move key string left\n\tin usage() for key-value parser",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "<libcamera-devel.lists.libcamera.org>",
        "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>",
        "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>",
        "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>",
        "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>",
        "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "When printing usage information for a key-value parser, the\ndocumentation of the keys and values is printed in the second column of\nthe usage text:\n\n  -s, --stream key=value[,key=value,...] ...            Set configuration of a camera stream\n                                                        height=integer          Height in pixels\n                                                        pixelformat=string      Pixel format name\n                                                        role=string             Role for the stream (viewfinder, video, still, raw)\n                                                        width=integer           Width in pixels\n  -h, --help                                            Display this help message\n\nThis results in long lines. Improve this by moving the key description\nto the first column, and aligning the value description as other option\ndescription text:\n\n  -s, --stream key=value[,key=value,...] ...            Set configuration of a camera stream\n          height=integer                                Height in pixels\n          pixelformat=string                            Pixel format name\n          role=string                                   Role for the stream (viewfinder, video, still, raw)\n          width=integer                                 Width in pixels\n  -h, --help                                            Display this help message\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/cam/options.cpp | 28 ++++++++++++++++++----------\n src/cam/options.h   |  1 +\n 2 files changed, 19 insertions(+), 10 deletions(-)",
    "diff": "diff --git a/src/cam/options.cpp b/src/cam/options.cpp\nindex f4fd8973f97a..4a88c38fb154 100644\n--- a/src/cam/options.cpp\n+++ b/src/cam/options.cpp\n@@ -411,27 +411,30 @@ KeyValueParser::Options KeyValueParser::parse(const char *arguments)\n \treturn options;\n }\n \n-void KeyValueParser::usage(int indent)\n+unsigned int KeyValueParser::maxOptionLength() const\n {\n-\tunsigned int space = 0;\n+\tunsigned int maxLength = 0;\n \n \tfor (auto const &iter : optionsMap_) {\n \t\tconst Option &option = iter.second;\n-\t\tunsigned int length = 14;\n+\t\tunsigned int length = 10 + strlen(option.name);\n \t\tif (option.argument != ArgumentNone)\n \t\t\tlength += 1 + strlen(option.typeName());\n \t\tif (option.argument == ArgumentOptional)\n \t\t\tlength += 2;\n \n-\t\tif (length > space)\n-\t\t\tspace = length;\n+\t\tif (length > maxLength)\n+\t\t\tmaxLength = length;\n \t}\n \n-\tspace = (space + 7) / 8 * 8;\n+\treturn maxLength;\n+}\n \n+void KeyValueParser::usage(int indent)\n+{\n \tfor (auto const &iter : optionsMap_) {\n \t\tconst Option &option = iter.second;\n-\t\tstd::string argument = option.name;\n+\t\tstd::string argument = std::string(\"          \") + option.name;\n \n \t\tif (option.argument != ArgumentNone) {\n \t\t\tif (option.argument == ArgumentOptional)\n@@ -443,14 +446,13 @@ void KeyValueParser::usage(int indent)\n \t\t\t\targument += \"]\";\n \t\t}\n \n-\t\tstd::cerr << std::setw(indent) << std::right << \" \"\n-\t\t\t  << std::setw(space) << std::left << argument;\n+\t\tstd::cerr << std::setw(indent) << std::left << argument;\n \n \t\tfor (const char *help = option.help, *end = help; end;) {\n \t\t\tend = strchr(help, '\\n');\n \t\t\tif (end) {\n \t\t\t\tstd::cerr << std::string(help, end - help + 1);\n-\t\t\t\tstd::cerr << std::setw(indent + space) << \" \";\n+\t\t\t\tstd::cerr << std::setw(indent) << \" \";\n \t\t\t\thelp = end + 1;\n \t\t\t} else {\n \t\t\t\tstd::cerr << help << std::endl;\n@@ -918,6 +920,12 @@ void OptionsParser::usage()\n \n \t\tif (length > indent)\n \t\t\tindent = length;\n+\n+\t\tif (option->keyValueParser) {\n+\t\t\tlength = option->keyValueParser->maxOptionLength();\n+\t\t\tif (length > indent)\n+\t\t\t\tindent = length;\n+\t\t}\n \t}\n \n \tindent = (indent + 7) / 8 * 8;\ndiff --git a/src/cam/options.h b/src/cam/options.h\nindex 4418e201bf1f..5c51a94c2f37 100644\n--- a/src/cam/options.h\n+++ b/src/cam/options.h\n@@ -72,6 +72,7 @@ private:\n \tKeyValueParser &operator=(const KeyValueParser &) = delete;\n \n \tfriend class OptionsParser;\n+\tunsigned int maxOptionLength() const;\n \tvoid usage(int indent);\n \n \tstd::map<std::string, Option> optionsMap_;\n",
    "prefixes": [
        "libcamera-devel",
        "08/30"
    ]
}