From de0330053584bad4dbb3dbd5e1ba939c4e8c6b55 Mon Sep 17 00:00:00 2001 From: Alejandro R Mosteo Date: Mon, 6 Nov 2023 11:14:21 +0100 Subject: [PATCH] Don't trigger help if requested after `--` (#32) Convention is that after `--` no more switches are to be parsed. --- src/clic-subcommand-instance.adb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/clic-subcommand-instance.adb b/src/clic-subcommand-instance.adb index 5b0bcd7..5f6e770 100644 --- a/src/clic-subcommand-instance.adb +++ b/src/clic-subcommand-instance.adb @@ -539,14 +539,20 @@ package body CLIC.Subcommand.Instance is Cmd_Line : constant AAA.Strings.Vector := (if Command_Line.Is_Empty then Ada_Command_Line else Command_Line); + Before_Double_Dash : Boolean := True; + -- After "--" a request for help is not directed to ourselves begin -- GNAT switch handling intercepts -h/--help. To have the same output -- for '
-h command' and '
help command', we do manual for Arg of Cmd_Line loop - if Arg not in "-h" | "--help" then - Arguments.Append (Arg); - else + if Arg = "--" then + Before_Double_Dash := False; + end if; + + if Before_Double_Dash and then Arg in "-h" | "--help" then Help_Requested := True; + else + Arguments.Append (Arg); end if; end loop; return To_Argument_List (Arguments);