From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 7DD74439FE;
	Mon, 29 Jan 2024 14:04:52 +0100 (CET)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 0872940DCD;
	Mon, 29 Jan 2024 14:04:52 +0100 (CET)
Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com
 [209.85.218.43]) by mails.dpdk.org (Postfix) with ESMTP id 7E9A3402C2
 for <dev@dpdk.org>; Mon, 29 Jan 2024 14:04:49 +0100 (CET)
Received: by mail-ej1-f43.google.com with SMTP id
 a640c23a62f3a-a35385da5bbso269045266b.3
 for <dev@dpdk.org>; Mon, 29 Jan 2024 05:04:49 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=pantheon.tech; s=google; t=1706533489; x=1707138289; darn=dpdk.org;
 h=content-transfer-encoding:cc:to:subject:message-id:date:from
 :in-reply-to:references:mime-version:from:to:cc:subject:date
 :message-id:reply-to;
 bh=V4QCeYmvX4IpxsXpauCgXO7ehyMYF2H0Os3DeM/igOw=;
 b=jZhnRR8G4Nnakbh9DI5C7TPNJbhQ9vqxVnz6pmBcwysZtyPjsMY3MmH8e/Io7BHsPN
 MrLRBXuI377exp1bjUO7VN/Gzgrv2moJf7GQu4PBlwqrs98GoYQXckiL+ouuNlmiWxF0
 FjCyu66ayv/Jvu2KqEFwoKErtQSJu+i6geqtVN/7dgnzUP1HZEHxPIlvu3jwdfooyPFl
 +KiEPPj9t6FR3OjKGpqxilVioFyYsFG9DSlWNyhCgtKXMKxRxS2sjOYLReyriKFiOZo5
 h+Y6zrmIDXp1Za4EzJRzJaapUWFVzF5RhZshfw/hfAY/YfTxvP8wct3XK1FIOvf874/S
 oGqQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1706533489; x=1707138289;
 h=content-transfer-encoding:cc:to:subject:message-id:date:from
 :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=V4QCeYmvX4IpxsXpauCgXO7ehyMYF2H0Os3DeM/igOw=;
 b=hy4oWzQYAUc2IG85xgQM+2I+RMrERpY2DA5ZPfMp1TCQNXP5J1nrN54OKFBGAs4TbH
 V2jBCTeLf/6LKCW31uWVwTnXuMbzFZ52kgSCbJBCxuUuDaZ26Z1/W1OVg+RzNHFJQeyg
 iYa8QNpP2SOpRPGdGAeRewuKNsMDzbaQcjQq78+yQ+RYuqHbEWA8bzcmmV8EXapc2IEt
 UC0Fd1d2P9grDTWUht+0/NknYMuh9lVWlpsw9s3Ve7DEl/bqscAoHkclogGv39Un4dHq
 j/bBwZPcHqLulZ9NDAM3H5yCnVq3R6HrQY59W6P+MB/m+durKsUo+dqYJwH+NKqZANPA
 lbMA==
X-Gm-Message-State: AOJu0YwrfSon5Q5GkjmkxvoCAfJg+dYalW8mTRx3BeNJKW3i2K1Oj2Vi
 pHtKGYWyeCN7fG9hWlVfpHCO2RpxZqkyFTTADqhIMVXB57bHH/LKcLtzN0uPuNUYdCRYuG+WR/P
 Qaf/xRLEPpsXBqbNGgcKaw+aEFcfL2fiU4u4k3ZgBYo/LtYh8FoA=
X-Google-Smtp-Source: AGHT+IFXp1GmQBBEXtEhalPKOvc83tYnuwUS29gIcyPDFxQ2T2JEw1h08Vx6mINBnQa08QJAkDeZDLzg7wM5W43qMeM=
X-Received: by 2002:a17:906:c44f:b0:a35:e9f1:9690 with SMTP id
 ck15-20020a170906c44f00b00a35e9f19690mr788211ejb.22.1706533489237; Mon, 29
 Jan 2024 05:04:49 -0800 (PST)
MIME-Version: 1.0
References: <20240122182611.1904974-1-luca.vizzarro@arm.com>
 <20240122182611.1904974-3-luca.vizzarro@arm.com>
In-Reply-To: <20240122182611.1904974-3-luca.vizzarro@arm.com>
From: =?UTF-8?Q?Juraj_Linke=C5=A1?= <juraj.linkes@pantheon.tech>
Date: Mon, 29 Jan 2024 14:04:38 +0100
Message-ID: <CAOb5WZZh8O5i6qbATqJ5ivGN4dPCpMW6_6Q3kD9O9YhPuxcNwA@mail.gmail.com>
Subject: Re: [PATCH 2/4] dts: customise argparse error message
To: Luca Vizzarro <luca.vizzarro@arm.com>
Cc: dev@dpdk.org, Paul Szczepanek <paul.szczepanek@arm.com>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
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>,
 <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>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

On Mon, Jan 22, 2024 at 7:26=E2=80=AFPM Luca Vizzarro <luca.vizzarro@arm.co=
m> wrote:
>
> This commit customises the arguments parsing class' error message,
> making it so the confusing usage is not displayed in these occurrences,

I'm curious, what exactly is confusing about the message?

> but the user is redirected to use the help argument instead.
>
> Reviewed-by: Paul Szczepanek <paul.szczepanek@arm.com>
> Signed-off-by: Luca Vizzarro <luca.vizzarro@arm.com>
> ---
>  dts/framework/settings.py | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/dts/framework/settings.py b/dts/framework/settings.py
> index 2d0365e763..acfe5cad44 100644
> --- a/dts/framework/settings.py
> +++ b/dts/framework/settings.py
> @@ -170,6 +170,15 @@ def _parse_revision_id(rev_id: str) -> str:
>          )
>
>
> +class ArgumentParser(argparse.ArgumentParser):
> +    """ArgumentParser with a custom error message."""
> +    def error(self, message):
> +        print(f"{self.prog}: error: {message}\n", file=3Dsys.stderr)
> +        self.exit(2,
> +                  "For help and usage, "
> +                  "run the command with the --help flag.\n")
> +
> +
>  @dataclass(slots=3DTrue)
>  class Settings:
>      """Default framework-wide user settings.
> @@ -200,8 +209,8 @@ class Settings:
>  SETTINGS: Settings =3D Settings()
>
>
> -def _get_parser() -> argparse.ArgumentParser:
> -    parser =3D argparse.ArgumentParser(
> +def _get_parser() -> ArgumentParser:
> +    parser =3D ArgumentParser(
>          description=3D"Run DPDK test suites. All options may be specifie=
d with the environment "
>          "variables provided in brackets. Command line arguments have hig=
her priority.",
>          formatter_class=3Dargparse.ArgumentDefaultsHelpFormatter,
> --
> 2.34.1
>