From c1304e9714677b7def912e163792e1f30467e06c Mon Sep 17 00:00:00 2001 From: Folkert Kevelam Date: Mon, 14 Jul 2025 22:13:58 +0200 Subject: [PATCH] Flesh out library idea some more --- .gitignore | 2 ++ {src => Source/Spec}/argument_parser.ads | 14 ++++++++++++++ argument_parser.gpr | 9 +++++++++ 3 files changed, 25 insertions(+) create mode 100644 .gitignore rename {src => Source/Spec}/argument_parser.ads (78%) create mode 100644 argument_parser.gpr diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d07f0ab --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +lib/ +obj/ diff --git a/src/argument_parser.ads b/Source/Spec/argument_parser.ads similarity index 78% rename from src/argument_parser.ads rename to Source/Spec/argument_parser.ads index b847041..340462f 100644 --- a/src/argument_parser.ads +++ b/Source/Spec/argument_parser.ads @@ -6,6 +6,14 @@ package Argument_Parser is function Parse (I : String) return Option is abstract; + type Argument_Parser is tagged private; + + function Parse (T : Argument_Parser) return Boolean; + + function Find (T : Argument_Parser; Key : String) return Option'Class; + + type Count is range 0 .. 2**31 - 1; + procedure Add_Positional ( Parser : in out Argument_Parser; Input_Type : Option'Class; @@ -37,6 +45,8 @@ package Argument_Parser is overriding function Parse (I : String) return String_Option; + function Value (O : String_Option) return String; + type Integer_Option is new Option with record Value : Integer; @@ -45,6 +55,8 @@ package Argument_Parser is overriding function Parse (I : String) return Integer_Option; + function Value (O : Integer_Option) return Integer; + type Float_Option is new Option with record Value : Float; @@ -53,6 +65,8 @@ package Argument_Parser is overriding function Parse (I : String) return Float_Option; + function Value (O : Float_Option) return Float; + private type Argument_Parser is tagged null record; diff --git a/argument_parser.gpr b/argument_parser.gpr new file mode 100644 index 0000000..8af8304 --- /dev/null +++ b/argument_parser.gpr @@ -0,0 +1,9 @@ +library project Argument_Parser is + + for Source_Dirs use ("Source/Spec", "Source/Impl"); + for Object_Dir use "obj"; + for Library_Name use "Argument_Parser"; + for Library_Dir use "lib"; + for Library_Kind use "Static"; + +end Argument_Parser;