-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CLIC.Subcommand: add support for -- (double-dash) to stop sub-command…
… switch parsing
- Loading branch information
1 parent
50fa7ae
commit 5a1f323
Showing
11 changed files
with
189 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package body CLIC_Ex.Commands.Double_Dash is | ||
|
||
Upper_Case : aliased Boolean := False; | ||
|
||
------------- | ||
-- Execute -- | ||
------------- | ||
|
||
overriding | ||
procedure Execute (Cmd : in out Instance; Args : AAA.Strings.Vector) | ||
is | ||
begin | ||
if Upper_Case then | ||
Ada.Text_IO.Put_Line (AAA.Strings.To_Upper_Case (Args.Flatten)); | ||
else | ||
Ada.Text_IO.Put_Line (Args.Flatten); | ||
end if; | ||
|
||
end Execute; | ||
|
||
-------------------- | ||
-- Setup_Switches -- | ||
-------------------- | ||
|
||
overriding | ||
procedure Setup_Switches | ||
(Cmd : in out Instance; | ||
Config : in out CLIC.Subcommand.Switches_Configuration) | ||
is | ||
begin | ||
CLIC.Subcommand.Define_Switch (Config, | ||
Output => Upper_Case'Access, | ||
Long_Switch => "--upper"); | ||
end Setup_Switches; | ||
|
||
end CLIC_Ex.Commands.Double_Dash; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
with AAA.Strings; | ||
|
||
with CLIC.Subcommand; | ||
|
||
package CLIC_Ex.Commands.Double_Dash is | ||
|
||
type Instance | ||
is new CLIC.Subcommand.Command | ||
with private; | ||
|
||
overriding | ||
function Name (Cmd : Instance) return CLIC.Subcommand.Identifier | ||
is ("double_dash"); | ||
|
||
overriding | ||
function Switch_Parsing (This : Instance) | ||
return CLIC.Subcommand.Switch_Parsing_Kind | ||
is (CLIC.Subcommand.Before_Double_Dash); | ||
|
||
overriding | ||
procedure Execute (Cmd : in out Instance; | ||
Args : AAA.Strings.Vector); | ||
|
||
overriding | ||
function Long_Description (Cmd : Instance) return AAA.Strings.Vector | ||
is (AAA.Strings.Empty_Vector); | ||
|
||
overriding | ||
procedure Setup_Switches | ||
(Cmd : in out Instance; | ||
Config : in out CLIC.Subcommand.Switches_Configuration); | ||
|
||
overriding | ||
function Short_Description (Cmd : Instance) return String | ||
is ("Switch parsing before -- (double dash)"); | ||
|
||
overriding | ||
function Usage_Custom_Parameters (Cmd : Instance) return String | ||
is ("[--upper] [--] [args]"); | ||
|
||
private | ||
|
||
type Instance | ||
is new CLIC.Subcommand.Command | ||
with null record; | ||
|
||
end CLIC_Ex.Commands.Double_Dash; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters