Skip to content

Commit

Permalink
Don't trigger help if requested after -- (#32)
Browse files Browse the repository at this point in the history
Convention is that after `--` no more switches are to be parsed.
  • Loading branch information
mosteo authored Nov 6, 2023
1 parent b40b170 commit de03300
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/clic-subcommand-instance.adb
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<main> -h command' and '<main> 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);
Expand Down

0 comments on commit de03300

Please sign in to comment.