From f57597ec32c8650a69c8c3b0058afb6b224bb16a Mon Sep 17 00:00:00 2001 From: Vadim Godunko Date: Tue, 23 Jan 2024 18:34:26 +0400 Subject: [PATCH 1/3] Add names of name and value in description of the name-value options. --- source/os/implementation/vss-command_line-parsers.adb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/os/implementation/vss-command_line-parsers.adb b/source/os/implementation/vss-command_line-parsers.adb index 3375beb5..80131ebd 100644 --- a/source/os/implementation/vss-command_line-parsers.adb +++ b/source/os/implementation/vss-command_line-parsers.adb @@ -289,6 +289,14 @@ package body VSS.Command_Line.Parsers is Option_Text.Append (" <"); Option_Text.Append (Value_Option'Class (Option).Value_Name); Option_Text.Append (">"); + + elsif Option in Name_Value_Option'Class then + Option_Text.Append (" <"); + Option_Text.Append (Name_Value_Option'Class (Option).Name_Name); + Option_Text.Append ("="); + Option_Text.Append + (Name_Value_Option'Class (Option).Value_Name); + Option_Text.Append (">"); end if; Append_Option_Description (Option_Text, Option.Description); From 830666c0e92468132cf35a8932533b851262ede6 Mon Sep 17 00:00:00 2001 From: Vadim Godunko Date: Tue, 23 Jan 2024 18:37:50 +0400 Subject: [PATCH 2/3] Check that given option is defined option. --- .../implementation/vss-command_line-parsers.adb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/source/os/implementation/vss-command_line-parsers.adb b/source/os/implementation/vss-command_line-parsers.adb index 80131ebd..e98eca06 100644 --- a/source/os/implementation/vss-command_line-parsers.adb +++ b/source/os/implementation/vss-command_line-parsers.adb @@ -838,12 +838,18 @@ package body VSS.Command_Line.Parsers is Option : Multivalue_Positional_Option'Class) return VSS.String_Vectors.Virtual_String_Vector is begin - return - Self.Positional_Options_Values.Slice - (Natural (Self.Defined_Positional_Options.Length) + 1, - Self.Positional_Options_Values.Length); + if not Self.Defined_Multivalue_Option.Is_Empty + and then Self.Defined_Multivalue_Option.Element + = Multivalue_Positional_Option (Option) + then + return + Self.Positional_Options_Values.Slice + (Natural (Self.Defined_Positional_Options.Length) + 1, + Self.Positional_Options_Values.Length); - return VSS.String_Vectors.Empty_Virtual_String_Vector; + else + return VSS.String_Vectors.Empty_Virtual_String_Vector; + end if; end Values; end VSS.Command_Line.Parsers; From 37eb89a3952cde8f22093fe291ba165fa1d4fa82 Mon Sep 17 00:00:00 2001 From: Vadim Godunko Date: Tue, 23 Jan 2024 18:39:29 +0400 Subject: [PATCH 3/3] Rename member. --- .../vss-command_line-parsers.adb | 29 ++++++++++--------- source/os/vss-command_line-parsers.ads | 2 +- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/source/os/implementation/vss-command_line-parsers.adb b/source/os/implementation/vss-command_line-parsers.adb index e98eca06..66223231 100644 --- a/source/os/implementation/vss-command_line-parsers.adb +++ b/source/os/implementation/vss-command_line-parsers.adb @@ -75,7 +75,7 @@ package body VSS.Command_Line.Parsers is end if; elsif Option in Multivalue_Positional_Option'Class then - Self.Defined_Multivalue_Option.Replace_Element + Self.Defined_Multivalue_Positional_Option.Replace_Element (Multivalue_Positional_Option (Option)); else @@ -254,9 +254,10 @@ package body VSS.Command_Line.Parsers is Usage.Append (Option.Name); end loop; - if not Self.Defined_Multivalue_Option.Is_Empty then + if not Self.Defined_Multivalue_Positional_Option.Is_Empty then Usage.Append (' '); - Usage.Append (Self.Defined_Multivalue_Option.Element.Name); + Usage.Append + (Self.Defined_Multivalue_Positional_Option.Element.Name); Usage.Append ('…'); end if; @@ -304,7 +305,7 @@ package body VSS.Command_Line.Parsers is end if; if not Self.Defined_Positional_Options.Is_Empty - or else not Self.Defined_Multivalue_Option.Is_Empty + or else not Self.Defined_Multivalue_Positional_Option.Is_Empty then Result.Append (VSS.Strings.Empty_Virtual_String); Result.Append ("Arguments:"); @@ -320,13 +321,15 @@ package body VSS.Command_Line.Parsers is end loop; end if; - if not Self.Defined_Multivalue_Option.Is_Empty then + if not Self.Defined_Multivalue_Positional_Option.Is_Empty then Option_Text.Clear; Option_Text.Append (" "); - Option_Text.Append (Self.Defined_Multivalue_Option.Element.Name); + Option_Text.Append + (Self.Defined_Multivalue_Positional_Option.Element.Name); Append_Option_Description - (Option_Text, Self.Defined_Multivalue_Option.Element.Description); + (Option_Text, + Self.Defined_Multivalue_Positional_Option.Element.Description); end if; return Result; @@ -347,8 +350,8 @@ package body VSS.Command_Line.Parsers is elsif Option in Multivalue_Positional_Option'Class then return - not Self.Defined_Multivalue_Option.Is_Empty - and then Self.Defined_Multivalue_Option.Element + not Self.Defined_Multivalue_Positional_Option.Is_Empty + and then Self.Defined_Multivalue_Positional_Option.Element = Multivalue_Positional_Option (Option) and then Natural (Self.Defined_Positional_Options.Length) < Self.Positional_Options_Values.Length; @@ -655,7 +658,7 @@ package body VSS.Command_Line.Parsers is else if Self.Defined_Positional_Options.Is_Empty then - if Self.Defined_Multivalue_Option.Is_Empty then + if Self.Defined_Multivalue_Positional_Option.Is_Empty then Self.Error_Message := "unexpected positional argument"; Success := False; @@ -666,7 +669,7 @@ package body VSS.Command_Line.Parsers is if Self.Positional_Options_Values.Length = Natural (Self.Defined_Positional_Options.Length) then - if Self.Defined_Multivalue_Option.Is_Empty then + if Self.Defined_Multivalue_Positional_Option.Is_Empty then Self.Error_Message := "unexpected positional argument"; Success := False; @@ -838,8 +841,8 @@ package body VSS.Command_Line.Parsers is Option : Multivalue_Positional_Option'Class) return VSS.String_Vectors.Virtual_String_Vector is begin - if not Self.Defined_Multivalue_Option.Is_Empty - and then Self.Defined_Multivalue_Option.Element + if not Self.Defined_Multivalue_Positional_Option.Is_Empty + and then Self.Defined_Multivalue_Positional_Option.Element = Multivalue_Positional_Option (Option) then return diff --git a/source/os/vss-command_line-parsers.ads b/source/os/vss-command_line-parsers.ads index 7a9d19f5..fd93dc0c 100644 --- a/source/os/vss-command_line-parsers.ads +++ b/source/os/vss-command_line-parsers.ads @@ -127,7 +127,7 @@ private Defined_Long_Options : Name_Sets.Set; Defined_Named_Options : Named_Option_Maps.Map; Defined_Positional_Options : Positional_Option_Vectors.Vector; - Defined_Multivalue_Option : + Defined_Multivalue_Positional_Option : Multivalue_Positional_Option_Holders.Holder; Error_Message : VSS.Strings.Virtual_String;