(Cmd : in out Command_Line;
Switch : String;
Parameter : String := "";
- Separator : Character := ' ';
+ Separator : Character := ASCII.NUL;
Section : String := "";
Add_Before : Boolean := False)
is
(Cmd : in out Command_Line;
Switch : String;
Parameter : String := "";
- Separator : Character := ' ';
+ Separator : Character := ASCII.NUL;
Section : String := "";
Add_Before : Boolean := False;
Success : out Boolean)
is
- pragma Unreferenced (Separator); -- ??? Should be removed eventually
-
procedure Add_Simple_Switch
(Simple : String;
- Separator : String;
+ Sepa : String;
Param : String;
Index : Integer);
-- Add a new switch that has had all its aliases expanded, and switches
procedure Add_Simple_Switch
(Simple : String;
- Separator : String;
+ Sepa : String;
Param : String;
Index : Integer)
is
with "Invalid switch " & Simple;
end if;
- if Separator = "" then
+ if Separator /= ASCII.NUL then
+ Sep := Separator;
+
+ elsif Sepa = "" then
Sep := ASCII.NUL;
else
- Sep := Separator (Separator'First);
+ Sep := Sepa (Sepa'First);
end if;
if Cmd.Expanded = null then
-- format (trailing ':', '?', etc for defining a switch with parameters).
--
-- Switch should also start with the leading '-' (or any other characters).
- -- They should all start with the same character, though. If this
- -- character is not '-', you will need to call Initialize_Option_Scan to
- -- set the proper character for the parser.
+ -- If this character is not '-', you will need to call
+ -- Initialize_Option_Scan to set the proper character for the parser.
--
-- The switches defined in the command_line_configuration object are used
-- when ungrouping switches with more that one character after the prefix.
(Cmd : in out Command_Line;
Switch : String;
Parameter : String := "";
- Separator : Character := ' ';
+ Separator : Character := ASCII.NUL;
Section : String := "";
Add_Before : Boolean := False);
-- Add a new switch to the command line, and combine/group it with existing
-- added if not already present. For example, to add the -g switch into the
-- -cargs section, you need to call (Cmd, "-g", Section => "-cargs").
--
- -- [Separator] is ignored, and kept for backward compatibility only.
- -- ??? It might be removed in future versions.
+ -- [Separator], if specified, overrides the separator that was defined
+ -- through Define_Switch. For instance, if the switch was defined as
+ -- "-from:", the separator defaults to a space. But if your application
+ -- uses unusual separators not supported by GNAT.Command_Line (for instance
+ -- it requires ":"), you can specify this separator here.
+ -- For instance,
+ -- Add_Switch(Cmd, "-from", "bar", ':')
+ -- results in
+ -- -from:bar
+ -- rather than the default
+ -- -from bar
+ --
+ -- Note however that Getopt doesn't know how to handle ":" as a separator.
+ -- So the recommendation is to declare the switch as "-from!" (ie no
+ -- space between the switch and its parameter). Then Getopt will return
+ -- ":bar" as the parameter, and you can trim the ":" in your application.
--
-- Invalid_Section is raised if Section was not defined in the
-- configuration of the command line.
(Cmd : in out Command_Line;
Switch : String;
Parameter : String := "";
- Separator : Character := ' ';
+ Separator : Character := ASCII.NUL;
Section : String := "";
Add_Before : Boolean := False;
Success : out Boolean);