First line of implementation

This commit is contained in:
Smaug123
2025-04-14 22:52:18 +01:00
parent 67eb89cfc0
commit 963a097360
2 changed files with 352 additions and 75 deletions

View File

@@ -11,14 +11,14 @@
namespace ArgParserHelpers namespace ArgParserHelpers
/// Helper types for arg parsing /// Helper types for arg parsing
module private ArgParseHelpers_ConsumePlugin = module internal ArgParseHelpers_ConsumePlugin =
open System open System
open System.IO open System.IO
open WoofWare.Myriad.Plugins open WoofWare.Myriad.Plugins
open ConsumePlugin open ConsumePlugin
/// A partially-parsed BasicNoPositionals. /// A partially-parsed BasicNoPositionals.
type private BasicNoPositionals_InProgress = type internal BasicNoPositionals_InProgress =
{ {
mutable Bar : string option mutable Bar : string option
mutable Baz : bool option mutable Baz : bool option
@@ -67,8 +67,16 @@ module private ArgParseHelpers_ConsumePlugin =
else else
errors |> Seq.toList |> Error errors |> Seq.toList |> Error
static member _Empty () : BasicNoPositionals_InProgress =
{
Bar = None
Baz = None
Foo = None
Rest = ResizeArray ()
}
/// A partially-parsed Basic. /// A partially-parsed Basic.
type private Basic_InProgress = type internal Basic_InProgress =
{ {
mutable Bar : string option mutable Bar : string option
mutable Baz : bool option mutable Baz : bool option
@@ -124,8 +132,16 @@ module private ArgParseHelpers_ConsumePlugin =
else else
errors |> Seq.toList |> Error errors |> Seq.toList |> Error
static member _Empty () : Basic_InProgress =
{
Bar = None
Baz = None
Foo = None
Rest = ResizeArray ()
}
/// A partially-parsed BasicWithIntPositionals. /// A partially-parsed BasicWithIntPositionals.
type private BasicWithIntPositionals_InProgress = type internal BasicWithIntPositionals_InProgress =
{ {
mutable Bar : string option mutable Bar : string option
mutable Baz : bool option mutable Baz : bool option
@@ -181,8 +197,16 @@ module private ArgParseHelpers_ConsumePlugin =
else else
errors |> Seq.toList |> Error errors |> Seq.toList |> Error
static member _Empty () : BasicWithIntPositionals_InProgress =
{
Bar = None
Baz = None
Foo = None
Rest = ResizeArray ()
}
/// A partially-parsed LoadsOfTypes. /// A partially-parsed LoadsOfTypes.
type private LoadsOfTypes_InProgress = type internal LoadsOfTypes_InProgress =
{ {
mutable AnotherOptionalThing : int option mutable AnotherOptionalThing : int option
mutable Bar : string option mutable Bar : string option
@@ -284,8 +308,23 @@ module private ArgParseHelpers_ConsumePlugin =
else else
errors |> Seq.toList |> Error errors |> Seq.toList |> Error
static member _Empty () : LoadsOfTypes_InProgress =
{
AnotherOptionalThing = None
Bar = None
Baz = None
Foo = None
OptionalThing = None
OptionalThingWithNoDefault = None
Positionals = ResizeArray ()
SomeDirectory = None
SomeFile = None
SomeList = ResizeArray ()
YetAnotherOptionalThing = None
}
/// A partially-parsed LoadsOfTypesNoPositionals. /// A partially-parsed LoadsOfTypesNoPositionals.
type private LoadsOfTypesNoPositionals_InProgress = type internal LoadsOfTypesNoPositionals_InProgress =
{ {
mutable AnotherOptionalThing : int option mutable AnotherOptionalThing : int option
mutable Bar : string option mutable Bar : string option
@@ -376,8 +415,22 @@ module private ArgParseHelpers_ConsumePlugin =
else else
errors |> Seq.toList |> Error errors |> Seq.toList |> Error
static member _Empty () : LoadsOfTypesNoPositionals_InProgress =
{
AnotherOptionalThing = None
Bar = None
Baz = None
Foo = None
OptionalThing = None
OptionalThingWithNoDefault = None
SomeDirectory = None
SomeFile = None
SomeList = ResizeArray ()
YetAnotherOptionalThing = None
}
/// A partially-parsed DatesAndTimes. /// A partially-parsed DatesAndTimes.
type private DatesAndTimes_InProgress = type internal DatesAndTimes_InProgress =
{ {
mutable Exact : TimeSpan option mutable Exact : TimeSpan option
mutable Invariant : TimeSpan option mutable Invariant : TimeSpan option
@@ -431,8 +484,16 @@ module private ArgParseHelpers_ConsumePlugin =
else else
errors |> Seq.toList |> Error errors |> Seq.toList |> Error
static member _Empty () : DatesAndTimes_InProgress =
{
Exact = None
Invariant = None
InvariantExact = None
Plain = None
}
/// A partially-parsed ChildRecord. /// A partially-parsed ChildRecord.
type private ChildRecord_InProgress = type internal ChildRecord_InProgress =
{ {
mutable Thing1 : int option mutable Thing1 : int option
mutable Thing2 : string option mutable Thing2 : string option
@@ -468,8 +529,14 @@ module private ArgParseHelpers_ConsumePlugin =
else else
errors |> Seq.toList |> Error errors |> Seq.toList |> Error
static member _Empty () : ChildRecord_InProgress =
{
Thing1 = None
Thing2 = None
}
/// A partially-parsed ParentRecord. /// A partially-parsed ParentRecord.
type private ParentRecord_InProgress = type internal ParentRecord_InProgress =
{ {
mutable AndAnother : bool option mutable AndAnother : bool option
mutable Child : ChildRecord_InProgress mutable Child : ChildRecord_InProgress
@@ -505,8 +572,14 @@ module private ArgParseHelpers_ConsumePlugin =
else else
errors |> Seq.toList |> Error errors |> Seq.toList |> Error
static member _Empty () : ParentRecord_InProgress =
{
AndAnother = None
Child = ChildRecord_InProgress._Empty ()
}
/// A partially-parsed ChildRecordWithPositional. /// A partially-parsed ChildRecordWithPositional.
type private ChildRecordWithPositional_InProgress = type internal ChildRecordWithPositional_InProgress =
{ {
mutable Thing1 : int option mutable Thing1 : int option
mutable Thing2 : ResizeArray<Uri> mutable Thing2 : ResizeArray<Uri>
@@ -544,8 +617,14 @@ module private ArgParseHelpers_ConsumePlugin =
else else
errors |> Seq.toList |> Error errors |> Seq.toList |> Error
static member _Empty () : ChildRecordWithPositional_InProgress =
{
Thing1 = None
Thing2 = ResizeArray ()
}
/// A partially-parsed ParentRecordChildPos. /// A partially-parsed ParentRecordChildPos.
type private ParentRecordChildPos_InProgress = type internal ParentRecordChildPos_InProgress =
{ {
mutable AndAnother : bool option mutable AndAnother : bool option
mutable Child : ChildRecordWithPositional_InProgress mutable Child : ChildRecordWithPositional_InProgress
@@ -581,8 +660,14 @@ module private ArgParseHelpers_ConsumePlugin =
else else
errors |> Seq.toList |> Error errors |> Seq.toList |> Error
static member _Empty () : ParentRecordChildPos_InProgress =
{
AndAnother = None
Child = ChildRecordWithPositional_InProgress._Empty ()
}
/// A partially-parsed ParentRecordSelfPos. /// A partially-parsed ParentRecordSelfPos.
type private ParentRecordSelfPos_InProgress = type internal ParentRecordSelfPos_InProgress =
{ {
mutable AndAnother : ResizeArray<bool> mutable AndAnother : ResizeArray<bool>
mutable Child : ChildRecord_InProgress mutable Child : ChildRecord_InProgress
@@ -620,8 +705,14 @@ module private ArgParseHelpers_ConsumePlugin =
else else
errors |> Seq.toList |> Error errors |> Seq.toList |> Error
static member _Empty () : ParentRecordSelfPos_InProgress =
{
AndAnother = ResizeArray ()
Child = ChildRecord_InProgress._Empty ()
}
/// A partially-parsed ChoicePositionals. /// A partially-parsed ChoicePositionals.
type private ChoicePositionals_InProgress = type internal ChoicePositionals_InProgress =
{ {
mutable Args : ResizeArray<string> mutable Args : ResizeArray<string>
} }
@@ -649,8 +740,13 @@ module private ArgParseHelpers_ConsumePlugin =
else else
errors |> Seq.toList |> Error errors |> Seq.toList |> Error
static member _Empty () : ChoicePositionals_InProgress =
{
Args = ResizeArray ()
}
/// A partially-parsed ContainsBoolEnvVar. /// A partially-parsed ContainsBoolEnvVar.
type private ContainsBoolEnvVar_InProgress = type internal ContainsBoolEnvVar_InProgress =
{ {
mutable BoolVar : bool option mutable BoolVar : bool option
} }
@@ -680,8 +776,13 @@ module private ArgParseHelpers_ConsumePlugin =
else else
errors |> Seq.toList |> Error errors |> Seq.toList |> Error
static member _Empty () : ContainsBoolEnvVar_InProgress =
{
BoolVar = None
}
/// A partially-parsed WithFlagDu. /// A partially-parsed WithFlagDu.
type private WithFlagDu_InProgress = type internal WithFlagDu_InProgress =
{ {
mutable DryRun : DryRunMode option mutable DryRun : DryRunMode option
} }
@@ -708,8 +809,13 @@ module private ArgParseHelpers_ConsumePlugin =
else else
errors |> Seq.toList |> Error errors |> Seq.toList |> Error
static member _Empty () : WithFlagDu_InProgress =
{
DryRun = None
}
/// A partially-parsed ContainsFlagEnvVar. /// A partially-parsed ContainsFlagEnvVar.
type private ContainsFlagEnvVar_InProgress = type internal ContainsFlagEnvVar_InProgress =
{ {
mutable DryRun : DryRunMode option mutable DryRun : DryRunMode option
} }
@@ -744,8 +850,13 @@ module private ArgParseHelpers_ConsumePlugin =
else else
errors |> Seq.toList |> Error errors |> Seq.toList |> Error
static member _Empty () : ContainsFlagEnvVar_InProgress =
{
DryRun = None
}
/// A partially-parsed ContainsFlagDefaultValue. /// A partially-parsed ContainsFlagDefaultValue.
type private ContainsFlagDefaultValue_InProgress = type internal ContainsFlagDefaultValue_InProgress =
{ {
mutable DryRun : DryRunMode option mutable DryRun : DryRunMode option
} }
@@ -770,8 +881,13 @@ module private ArgParseHelpers_ConsumePlugin =
else else
errors |> Seq.toList |> Error errors |> Seq.toList |> Error
static member _Empty () : ContainsFlagDefaultValue_InProgress =
{
DryRun = None
}
/// A partially-parsed ManyLongForms. /// A partially-parsed ManyLongForms.
type private ManyLongForms_InProgress = type internal ManyLongForms_InProgress =
{ {
mutable DoTheThing : string option mutable DoTheThing : string option
mutable SomeFlag : bool option mutable SomeFlag : bool option
@@ -807,8 +923,14 @@ module private ArgParseHelpers_ConsumePlugin =
else else
errors |> Seq.toList |> Error errors |> Seq.toList |> Error
static member _Empty () : ManyLongForms_InProgress =
{
DoTheThing = None
SomeFlag = None
}
/// A partially-parsed FlagsIntoPositionalArgs. /// A partially-parsed FlagsIntoPositionalArgs.
type private FlagsIntoPositionalArgs_InProgress = type internal FlagsIntoPositionalArgs_InProgress =
{ {
mutable A : string option mutable A : string option
mutable GrabEverything : ResizeArray<string> mutable GrabEverything : ResizeArray<string>
@@ -846,8 +968,14 @@ module private ArgParseHelpers_ConsumePlugin =
else else
errors |> Seq.toList |> Error errors |> Seq.toList |> Error
static member _Empty () : FlagsIntoPositionalArgs_InProgress =
{
A = None
GrabEverything = ResizeArray ()
}
/// A partially-parsed FlagsIntoPositionalArgsChoice. /// A partially-parsed FlagsIntoPositionalArgsChoice.
type private FlagsIntoPositionalArgsChoice_InProgress = type internal FlagsIntoPositionalArgsChoice_InProgress =
{ {
mutable A : string option mutable A : string option
mutable GrabEverything : ResizeArray<string> mutable GrabEverything : ResizeArray<string>
@@ -884,8 +1012,14 @@ module private ArgParseHelpers_ConsumePlugin =
else else
errors |> Seq.toList |> Error errors |> Seq.toList |> Error
static member _Empty () : FlagsIntoPositionalArgsChoice_InProgress =
{
A = None
GrabEverything = ResizeArray ()
}
/// A partially-parsed FlagsIntoPositionalArgsInt. /// A partially-parsed FlagsIntoPositionalArgsInt.
type private FlagsIntoPositionalArgsInt_InProgress = type internal FlagsIntoPositionalArgsInt_InProgress =
{ {
mutable A : string option mutable A : string option
mutable GrabEverything : ResizeArray<int> mutable GrabEverything : ResizeArray<int>
@@ -923,8 +1057,14 @@ module private ArgParseHelpers_ConsumePlugin =
else else
errors |> Seq.toList |> Error errors |> Seq.toList |> Error
static member _Empty () : FlagsIntoPositionalArgsInt_InProgress =
{
A = None
GrabEverything = ResizeArray ()
}
/// A partially-parsed FlagsIntoPositionalArgsIntChoice. /// A partially-parsed FlagsIntoPositionalArgsIntChoice.
type private FlagsIntoPositionalArgsIntChoice_InProgress = type internal FlagsIntoPositionalArgsIntChoice_InProgress =
{ {
mutable A : string option mutable A : string option
mutable GrabEverything : ResizeArray<int> mutable GrabEverything : ResizeArray<int>
@@ -961,8 +1101,14 @@ module private ArgParseHelpers_ConsumePlugin =
else else
errors |> Seq.toList |> Error errors |> Seq.toList |> Error
static member _Empty () : FlagsIntoPositionalArgsIntChoice_InProgress =
{
A = None
GrabEverything = ResizeArray ()
}
/// A partially-parsed FlagsIntoPositionalArgs'. /// A partially-parsed FlagsIntoPositionalArgs'.
type private FlagsIntoPositionalArgs'_InProgress = type internal FlagsIntoPositionalArgs'_InProgress =
{ {
mutable A : string option mutable A : string option
mutable DontGrabEverything : ResizeArray<string> mutable DontGrabEverything : ResizeArray<string>
@@ -999,8 +1145,15 @@ module private ArgParseHelpers_ConsumePlugin =
} }
else else
errors |> Seq.toList |> Error errors |> Seq.toList |> Error
static member _Empty () : FlagsIntoPositionalArgs'_InProgress =
{
A = None
DontGrabEverything = ResizeArray ()
}
namespace ConsumePlugin namespace ConsumePlugin
open ArgParserHelpers
open System open System
open System.IO open System.IO
open WoofWare.Myriad.Plugins open WoofWare.Myriad.Plugins
@@ -1008,7 +1161,7 @@ open WoofWare.Myriad.Plugins
/// Methods to parse arguments for the type FlagsIntoPositionalArgs' /// Methods to parse arguments for the type FlagsIntoPositionalArgs'
[<AutoOpen>] [<AutoOpen>]
module FlagsIntoPositionalArgs'ArgParse = module FlagsIntoPositionalArgs'ArgParse =
type private ParseState_FlagsIntoPositionalArgs' = type internal ParseState_FlagsIntoPositionalArgs' =
/// Ready to consume a key or positional arg /// Ready to consume a key or positional arg
| AwaitingKey | AwaitingKey
/// Waiting to receive a value for the key we've already consumed /// Waiting to receive a value for the key we've already consumed
@@ -1022,12 +1175,16 @@ module FlagsIntoPositionalArgs'ArgParse =
(args : string list) (args : string list)
: FlagsIntoPositionalArgs' : FlagsIntoPositionalArgs'
= =
let inProgress =
ArgParseHelpers_ConsumePlugin.FlagsIntoPositionalArgs'_InProgress._Empty ()
failwith "todo" failwith "todo"
static member parse (args : string list) : FlagsIntoPositionalArgs' = static member parse (args : string list) : FlagsIntoPositionalArgs' =
FlagsIntoPositionalArgs'.parse' System.Environment.GetEnvironmentVariable args FlagsIntoPositionalArgs'.parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open ArgParserHelpers
open System open System
open System.IO open System.IO
open WoofWare.Myriad.Plugins open WoofWare.Myriad.Plugins
@@ -1035,7 +1192,7 @@ open WoofWare.Myriad.Plugins
/// Methods to parse arguments for the type FlagsIntoPositionalArgsIntChoice /// Methods to parse arguments for the type FlagsIntoPositionalArgsIntChoice
[<AutoOpen>] [<AutoOpen>]
module FlagsIntoPositionalArgsIntChoiceArgParse = module FlagsIntoPositionalArgsIntChoiceArgParse =
type private ParseState_FlagsIntoPositionalArgsIntChoice = type internal ParseState_FlagsIntoPositionalArgsIntChoice =
/// Ready to consume a key or positional arg /// Ready to consume a key or positional arg
| AwaitingKey | AwaitingKey
/// Waiting to receive a value for the key we've already consumed /// Waiting to receive a value for the key we've already consumed
@@ -1049,12 +1206,16 @@ module FlagsIntoPositionalArgsIntChoiceArgParse =
(args : string list) (args : string list)
: FlagsIntoPositionalArgsIntChoice : FlagsIntoPositionalArgsIntChoice
= =
let inProgress =
ArgParseHelpers_ConsumePlugin.FlagsIntoPositionalArgsIntChoice_InProgress._Empty ()
failwith "todo" failwith "todo"
static member parse (args : string list) : FlagsIntoPositionalArgsIntChoice = static member parse (args : string list) : FlagsIntoPositionalArgsIntChoice =
FlagsIntoPositionalArgsIntChoice.parse' System.Environment.GetEnvironmentVariable args FlagsIntoPositionalArgsIntChoice.parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open ArgParserHelpers
open System open System
open System.IO open System.IO
open WoofWare.Myriad.Plugins open WoofWare.Myriad.Plugins
@@ -1062,7 +1223,7 @@ open WoofWare.Myriad.Plugins
/// Methods to parse arguments for the type FlagsIntoPositionalArgsInt /// Methods to parse arguments for the type FlagsIntoPositionalArgsInt
[<AutoOpen>] [<AutoOpen>]
module FlagsIntoPositionalArgsIntArgParse = module FlagsIntoPositionalArgsIntArgParse =
type private ParseState_FlagsIntoPositionalArgsInt = type internal ParseState_FlagsIntoPositionalArgsInt =
/// Ready to consume a key or positional arg /// Ready to consume a key or positional arg
| AwaitingKey | AwaitingKey
/// Waiting to receive a value for the key we've already consumed /// Waiting to receive a value for the key we've already consumed
@@ -1076,12 +1237,16 @@ module FlagsIntoPositionalArgsIntArgParse =
(args : string list) (args : string list)
: FlagsIntoPositionalArgsInt : FlagsIntoPositionalArgsInt
= =
let inProgress =
ArgParseHelpers_ConsumePlugin.FlagsIntoPositionalArgsInt_InProgress._Empty ()
failwith "todo" failwith "todo"
static member parse (args : string list) : FlagsIntoPositionalArgsInt = static member parse (args : string list) : FlagsIntoPositionalArgsInt =
FlagsIntoPositionalArgsInt.parse' System.Environment.GetEnvironmentVariable args FlagsIntoPositionalArgsInt.parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open ArgParserHelpers
open System open System
open System.IO open System.IO
open WoofWare.Myriad.Plugins open WoofWare.Myriad.Plugins
@@ -1089,7 +1254,7 @@ open WoofWare.Myriad.Plugins
/// Methods to parse arguments for the type FlagsIntoPositionalArgsChoice /// Methods to parse arguments for the type FlagsIntoPositionalArgsChoice
[<AutoOpen>] [<AutoOpen>]
module FlagsIntoPositionalArgsChoiceArgParse = module FlagsIntoPositionalArgsChoiceArgParse =
type private ParseState_FlagsIntoPositionalArgsChoice = type internal ParseState_FlagsIntoPositionalArgsChoice =
/// Ready to consume a key or positional arg /// Ready to consume a key or positional arg
| AwaitingKey | AwaitingKey
/// Waiting to receive a value for the key we've already consumed /// Waiting to receive a value for the key we've already consumed
@@ -1103,12 +1268,16 @@ module FlagsIntoPositionalArgsChoiceArgParse =
(args : string list) (args : string list)
: FlagsIntoPositionalArgsChoice : FlagsIntoPositionalArgsChoice
= =
let inProgress =
ArgParseHelpers_ConsumePlugin.FlagsIntoPositionalArgsChoice_InProgress._Empty ()
failwith "todo" failwith "todo"
static member parse (args : string list) : FlagsIntoPositionalArgsChoice = static member parse (args : string list) : FlagsIntoPositionalArgsChoice =
FlagsIntoPositionalArgsChoice.parse' System.Environment.GetEnvironmentVariable args FlagsIntoPositionalArgsChoice.parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open ArgParserHelpers
open System open System
open System.IO open System.IO
open WoofWare.Myriad.Plugins open WoofWare.Myriad.Plugins
@@ -1116,7 +1285,7 @@ open WoofWare.Myriad.Plugins
/// Methods to parse arguments for the type FlagsIntoPositionalArgs /// Methods to parse arguments for the type FlagsIntoPositionalArgs
[<AutoOpen>] [<AutoOpen>]
module FlagsIntoPositionalArgsArgParse = module FlagsIntoPositionalArgsArgParse =
type private ParseState_FlagsIntoPositionalArgs = type internal ParseState_FlagsIntoPositionalArgs =
/// Ready to consume a key or positional arg /// Ready to consume a key or positional arg
| AwaitingKey | AwaitingKey
/// Waiting to receive a value for the key we've already consumed /// Waiting to receive a value for the key we've already consumed
@@ -1130,12 +1299,16 @@ module FlagsIntoPositionalArgsArgParse =
(args : string list) (args : string list)
: FlagsIntoPositionalArgs : FlagsIntoPositionalArgs
= =
let inProgress =
ArgParseHelpers_ConsumePlugin.FlagsIntoPositionalArgs_InProgress._Empty ()
failwith "todo" failwith "todo"
static member parse (args : string list) : FlagsIntoPositionalArgs = static member parse (args : string list) : FlagsIntoPositionalArgs =
FlagsIntoPositionalArgs.parse' System.Environment.GetEnvironmentVariable args FlagsIntoPositionalArgs.parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open ArgParserHelpers
open System open System
open System.IO open System.IO
open WoofWare.Myriad.Plugins open WoofWare.Myriad.Plugins
@@ -1143,7 +1316,7 @@ open WoofWare.Myriad.Plugins
/// Methods to parse arguments for the type ManyLongForms /// Methods to parse arguments for the type ManyLongForms
[<AutoOpen>] [<AutoOpen>]
module ManyLongFormsArgParse = module ManyLongFormsArgParse =
type private ParseState_ManyLongForms = type internal ParseState_ManyLongForms =
/// Ready to consume a key or positional arg /// Ready to consume a key or positional arg
| AwaitingKey | AwaitingKey
/// Waiting to receive a value for the key we've already consumed /// Waiting to receive a value for the key we've already consumed
@@ -1153,12 +1326,14 @@ module ManyLongFormsArgParse =
type ManyLongForms with type ManyLongForms with
static member parse' (getEnvironmentVariable : string -> string) (args : string list) : ManyLongForms = static member parse' (getEnvironmentVariable : string -> string) (args : string list) : ManyLongForms =
let inProgress = ArgParseHelpers_ConsumePlugin.ManyLongForms_InProgress._Empty ()
failwith "todo" failwith "todo"
static member parse (args : string list) : ManyLongForms = static member parse (args : string list) : ManyLongForms =
ManyLongForms.parse' System.Environment.GetEnvironmentVariable args ManyLongForms.parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open ArgParserHelpers
open System open System
open System.IO open System.IO
open WoofWare.Myriad.Plugins open WoofWare.Myriad.Plugins
@@ -1166,7 +1341,7 @@ open WoofWare.Myriad.Plugins
/// Methods to parse arguments for the type ContainsFlagDefaultValue /// Methods to parse arguments for the type ContainsFlagDefaultValue
[<AutoOpen>] [<AutoOpen>]
module ContainsFlagDefaultValueArgParse = module ContainsFlagDefaultValueArgParse =
type private ParseState_ContainsFlagDefaultValue = type internal ParseState_ContainsFlagDefaultValue =
/// Ready to consume a key or positional arg /// Ready to consume a key or positional arg
| AwaitingKey | AwaitingKey
/// Waiting to receive a value for the key we've already consumed /// Waiting to receive a value for the key we've already consumed
@@ -1180,12 +1355,16 @@ module ContainsFlagDefaultValueArgParse =
(args : string list) (args : string list)
: ContainsFlagDefaultValue : ContainsFlagDefaultValue
= =
let inProgress =
ArgParseHelpers_ConsumePlugin.ContainsFlagDefaultValue_InProgress._Empty ()
failwith "todo" failwith "todo"
static member parse (args : string list) : ContainsFlagDefaultValue = static member parse (args : string list) : ContainsFlagDefaultValue =
ContainsFlagDefaultValue.parse' System.Environment.GetEnvironmentVariable args ContainsFlagDefaultValue.parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open ArgParserHelpers
open System open System
open System.IO open System.IO
open WoofWare.Myriad.Plugins open WoofWare.Myriad.Plugins
@@ -1193,7 +1372,7 @@ open WoofWare.Myriad.Plugins
/// Methods to parse arguments for the type ContainsFlagEnvVar /// Methods to parse arguments for the type ContainsFlagEnvVar
[<AutoOpen>] [<AutoOpen>]
module ContainsFlagEnvVarArgParse = module ContainsFlagEnvVarArgParse =
type private ParseState_ContainsFlagEnvVar = type internal ParseState_ContainsFlagEnvVar =
/// Ready to consume a key or positional arg /// Ready to consume a key or positional arg
| AwaitingKey | AwaitingKey
/// Waiting to receive a value for the key we've already consumed /// Waiting to receive a value for the key we've already consumed
@@ -1203,12 +1382,16 @@ module ContainsFlagEnvVarArgParse =
type ContainsFlagEnvVar with type ContainsFlagEnvVar with
static member parse' (getEnvironmentVariable : string -> string) (args : string list) : ContainsFlagEnvVar = static member parse' (getEnvironmentVariable : string -> string) (args : string list) : ContainsFlagEnvVar =
let inProgress =
ArgParseHelpers_ConsumePlugin.ContainsFlagEnvVar_InProgress._Empty ()
failwith "todo" failwith "todo"
static member parse (args : string list) : ContainsFlagEnvVar = static member parse (args : string list) : ContainsFlagEnvVar =
ContainsFlagEnvVar.parse' System.Environment.GetEnvironmentVariable args ContainsFlagEnvVar.parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open ArgParserHelpers
open System open System
open System.IO open System.IO
open WoofWare.Myriad.Plugins open WoofWare.Myriad.Plugins
@@ -1216,7 +1399,7 @@ open WoofWare.Myriad.Plugins
/// Methods to parse arguments for the type WithFlagDu /// Methods to parse arguments for the type WithFlagDu
[<AutoOpen>] [<AutoOpen>]
module WithFlagDuArgParse = module WithFlagDuArgParse =
type private ParseState_WithFlagDu = type internal ParseState_WithFlagDu =
/// Ready to consume a key or positional arg /// Ready to consume a key or positional arg
| AwaitingKey | AwaitingKey
/// Waiting to receive a value for the key we've already consumed /// Waiting to receive a value for the key we've already consumed
@@ -1226,12 +1409,14 @@ module WithFlagDuArgParse =
type WithFlagDu with type WithFlagDu with
static member parse' (getEnvironmentVariable : string -> string) (args : string list) : WithFlagDu = static member parse' (getEnvironmentVariable : string -> string) (args : string list) : WithFlagDu =
let inProgress = ArgParseHelpers_ConsumePlugin.WithFlagDu_InProgress._Empty ()
failwith "todo" failwith "todo"
static member parse (args : string list) : WithFlagDu = static member parse (args : string list) : WithFlagDu =
WithFlagDu.parse' System.Environment.GetEnvironmentVariable args WithFlagDu.parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open ArgParserHelpers
open System open System
open System.IO open System.IO
open WoofWare.Myriad.Plugins open WoofWare.Myriad.Plugins
@@ -1239,7 +1424,7 @@ open WoofWare.Myriad.Plugins
/// Methods to parse arguments for the type ContainsBoolEnvVar /// Methods to parse arguments for the type ContainsBoolEnvVar
[<AutoOpen>] [<AutoOpen>]
module ContainsBoolEnvVarArgParse = module ContainsBoolEnvVarArgParse =
type private ParseState_ContainsBoolEnvVar = type internal ParseState_ContainsBoolEnvVar =
/// Ready to consume a key or positional arg /// Ready to consume a key or positional arg
| AwaitingKey | AwaitingKey
/// Waiting to receive a value for the key we've already consumed /// Waiting to receive a value for the key we've already consumed
@@ -1249,12 +1434,16 @@ module ContainsBoolEnvVarArgParse =
type ContainsBoolEnvVar with type ContainsBoolEnvVar with
static member parse' (getEnvironmentVariable : string -> string) (args : string list) : ContainsBoolEnvVar = static member parse' (getEnvironmentVariable : string -> string) (args : string list) : ContainsBoolEnvVar =
let inProgress =
ArgParseHelpers_ConsumePlugin.ContainsBoolEnvVar_InProgress._Empty ()
failwith "todo" failwith "todo"
static member parse (args : string list) : ContainsBoolEnvVar = static member parse (args : string list) : ContainsBoolEnvVar =
ContainsBoolEnvVar.parse' System.Environment.GetEnvironmentVariable args ContainsBoolEnvVar.parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open ArgParserHelpers
open System open System
open System.IO open System.IO
open WoofWare.Myriad.Plugins open WoofWare.Myriad.Plugins
@@ -1262,7 +1451,7 @@ open WoofWare.Myriad.Plugins
/// Methods to parse arguments for the type ChoicePositionals /// Methods to parse arguments for the type ChoicePositionals
[<AutoOpen>] [<AutoOpen>]
module ChoicePositionalsArgParse = module ChoicePositionalsArgParse =
type private ParseState_ChoicePositionals = type internal ParseState_ChoicePositionals =
/// Ready to consume a key or positional arg /// Ready to consume a key or positional arg
| AwaitingKey | AwaitingKey
/// Waiting to receive a value for the key we've already consumed /// Waiting to receive a value for the key we've already consumed
@@ -1272,12 +1461,16 @@ module ChoicePositionalsArgParse =
type ChoicePositionals with type ChoicePositionals with
static member parse' (getEnvironmentVariable : string -> string) (args : string list) : ChoicePositionals = static member parse' (getEnvironmentVariable : string -> string) (args : string list) : ChoicePositionals =
let inProgress =
ArgParseHelpers_ConsumePlugin.ChoicePositionals_InProgress._Empty ()
failwith "todo" failwith "todo"
static member parse (args : string list) : ChoicePositionals = static member parse (args : string list) : ChoicePositionals =
ChoicePositionals.parse' System.Environment.GetEnvironmentVariable args ChoicePositionals.parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open ArgParserHelpers
open System open System
open System.IO open System.IO
open WoofWare.Myriad.Plugins open WoofWare.Myriad.Plugins
@@ -1285,7 +1478,7 @@ open WoofWare.Myriad.Plugins
/// Methods to parse arguments for the type ParentRecordSelfPos /// Methods to parse arguments for the type ParentRecordSelfPos
[<AutoOpen>] [<AutoOpen>]
module ParentRecordSelfPosArgParse = module ParentRecordSelfPosArgParse =
type private ParseState_ParentRecordSelfPos = type internal ParseState_ParentRecordSelfPos =
/// Ready to consume a key or positional arg /// Ready to consume a key or positional arg
| AwaitingKey | AwaitingKey
/// Waiting to receive a value for the key we've already consumed /// Waiting to receive a value for the key we've already consumed
@@ -1295,12 +1488,16 @@ module ParentRecordSelfPosArgParse =
type ParentRecordSelfPos with type ParentRecordSelfPos with
static member parse' (getEnvironmentVariable : string -> string) (args : string list) : ParentRecordSelfPos = static member parse' (getEnvironmentVariable : string -> string) (args : string list) : ParentRecordSelfPos =
let inProgress =
ArgParseHelpers_ConsumePlugin.ParentRecordSelfPos_InProgress._Empty ()
failwith "todo" failwith "todo"
static member parse (args : string list) : ParentRecordSelfPos = static member parse (args : string list) : ParentRecordSelfPos =
ParentRecordSelfPos.parse' System.Environment.GetEnvironmentVariable args ParentRecordSelfPos.parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open ArgParserHelpers
open System open System
open System.IO open System.IO
open WoofWare.Myriad.Plugins open WoofWare.Myriad.Plugins
@@ -1308,7 +1505,7 @@ open WoofWare.Myriad.Plugins
/// Methods to parse arguments for the type ParentRecordChildPos /// Methods to parse arguments for the type ParentRecordChildPos
[<AutoOpen>] [<AutoOpen>]
module ParentRecordChildPosArgParse = module ParentRecordChildPosArgParse =
type private ParseState_ParentRecordChildPos = type internal ParseState_ParentRecordChildPos =
/// Ready to consume a key or positional arg /// Ready to consume a key or positional arg
| AwaitingKey | AwaitingKey
/// Waiting to receive a value for the key we've already consumed /// Waiting to receive a value for the key we've already consumed
@@ -1318,12 +1515,16 @@ module ParentRecordChildPosArgParse =
type ParentRecordChildPos with type ParentRecordChildPos with
static member parse' (getEnvironmentVariable : string -> string) (args : string list) : ParentRecordChildPos = static member parse' (getEnvironmentVariable : string -> string) (args : string list) : ParentRecordChildPos =
let inProgress =
ArgParseHelpers_ConsumePlugin.ParentRecordChildPos_InProgress._Empty ()
failwith "todo" failwith "todo"
static member parse (args : string list) : ParentRecordChildPos = static member parse (args : string list) : ParentRecordChildPos =
ParentRecordChildPos.parse' System.Environment.GetEnvironmentVariable args ParentRecordChildPos.parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open ArgParserHelpers
open System open System
open System.IO open System.IO
open WoofWare.Myriad.Plugins open WoofWare.Myriad.Plugins
@@ -1331,7 +1532,7 @@ open WoofWare.Myriad.Plugins
/// Methods to parse arguments for the type ParentRecord /// Methods to parse arguments for the type ParentRecord
[<AutoOpen>] [<AutoOpen>]
module ParentRecordArgParse = module ParentRecordArgParse =
type private ParseState_ParentRecord = type internal ParseState_ParentRecord =
/// Ready to consume a key or positional arg /// Ready to consume a key or positional arg
| AwaitingKey | AwaitingKey
/// Waiting to receive a value for the key we've already consumed /// Waiting to receive a value for the key we've already consumed
@@ -1341,12 +1542,14 @@ module ParentRecordArgParse =
type ParentRecord with type ParentRecord with
static member parse' (getEnvironmentVariable : string -> string) (args : string list) : ParentRecord = static member parse' (getEnvironmentVariable : string -> string) (args : string list) : ParentRecord =
let inProgress = ArgParseHelpers_ConsumePlugin.ParentRecord_InProgress._Empty ()
failwith "todo" failwith "todo"
static member parse (args : string list) : ParentRecord = static member parse (args : string list) : ParentRecord =
ParentRecord.parse' System.Environment.GetEnvironmentVariable args ParentRecord.parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open ArgParserHelpers
open System open System
open System.IO open System.IO
open WoofWare.Myriad.Plugins open WoofWare.Myriad.Plugins
@@ -1354,7 +1557,7 @@ open WoofWare.Myriad.Plugins
/// Methods to parse arguments for the type DatesAndTimes /// Methods to parse arguments for the type DatesAndTimes
[<AutoOpen>] [<AutoOpen>]
module DatesAndTimesArgParse = module DatesAndTimesArgParse =
type private ParseState_DatesAndTimes = type internal ParseState_DatesAndTimes =
/// Ready to consume a key or positional arg /// Ready to consume a key or positional arg
| AwaitingKey | AwaitingKey
/// Waiting to receive a value for the key we've already consumed /// Waiting to receive a value for the key we've already consumed
@@ -1364,12 +1567,14 @@ module DatesAndTimesArgParse =
type DatesAndTimes with type DatesAndTimes with
static member parse' (getEnvironmentVariable : string -> string) (args : string list) : DatesAndTimes = static member parse' (getEnvironmentVariable : string -> string) (args : string list) : DatesAndTimes =
let inProgress = ArgParseHelpers_ConsumePlugin.DatesAndTimes_InProgress._Empty ()
failwith "todo" failwith "todo"
static member parse (args : string list) : DatesAndTimes = static member parse (args : string list) : DatesAndTimes =
DatesAndTimes.parse' System.Environment.GetEnvironmentVariable args DatesAndTimes.parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open ArgParserHelpers
open System open System
open System.IO open System.IO
open WoofWare.Myriad.Plugins open WoofWare.Myriad.Plugins
@@ -1377,19 +1582,23 @@ open WoofWare.Myriad.Plugins
/// Methods to parse arguments for the type LoadsOfTypesNoPositionals /// Methods to parse arguments for the type LoadsOfTypesNoPositionals
[<RequireQualifiedAccess ; CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>] [<RequireQualifiedAccess ; CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module LoadsOfTypesNoPositionals = module LoadsOfTypesNoPositionals =
type private ParseState_LoadsOfTypesNoPositionals = type internal ParseState_LoadsOfTypesNoPositionals =
/// Ready to consume a key or positional arg /// Ready to consume a key or positional arg
| AwaitingKey | AwaitingKey
/// Waiting to receive a value for the key we've already consumed /// Waiting to receive a value for the key we've already consumed
| AwaitingValue of key : string | AwaitingValue of key : string
let parse' (getEnvironmentVariable : string -> string) (args : string list) : LoadsOfTypesNoPositionals = let parse' (getEnvironmentVariable : string -> string) (args : string list) : LoadsOfTypesNoPositionals =
let inProgress =
ArgParseHelpers_ConsumePlugin.LoadsOfTypesNoPositionals_InProgress._Empty ()
failwith "todo" failwith "todo"
let parse (args : string list) : LoadsOfTypesNoPositionals = let parse (args : string list) : LoadsOfTypesNoPositionals =
parse' System.Environment.GetEnvironmentVariable args parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open ArgParserHelpers
open System open System
open System.IO open System.IO
open WoofWare.Myriad.Plugins open WoofWare.Myriad.Plugins
@@ -1397,18 +1606,21 @@ open WoofWare.Myriad.Plugins
/// Methods to parse arguments for the type LoadsOfTypes /// Methods to parse arguments for the type LoadsOfTypes
[<RequireQualifiedAccess ; CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>] [<RequireQualifiedAccess ; CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module LoadsOfTypes = module LoadsOfTypes =
type private ParseState_LoadsOfTypes = type internal ParseState_LoadsOfTypes =
/// Ready to consume a key or positional arg /// Ready to consume a key or positional arg
| AwaitingKey | AwaitingKey
/// Waiting to receive a value for the key we've already consumed /// Waiting to receive a value for the key we've already consumed
| AwaitingValue of key : string | AwaitingValue of key : string
let parse' (getEnvironmentVariable : string -> string) (args : string list) : LoadsOfTypes = failwith "todo" let parse' (getEnvironmentVariable : string -> string) (args : string list) : LoadsOfTypes =
let inProgress = ArgParseHelpers_ConsumePlugin.LoadsOfTypes_InProgress._Empty ()
failwith "todo"
let parse (args : string list) : LoadsOfTypes = let parse (args : string list) : LoadsOfTypes =
parse' System.Environment.GetEnvironmentVariable args parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open ArgParserHelpers
open System open System
open System.IO open System.IO
open WoofWare.Myriad.Plugins open WoofWare.Myriad.Plugins
@@ -1416,19 +1628,23 @@ open WoofWare.Myriad.Plugins
/// Methods to parse arguments for the type BasicWithIntPositionals /// Methods to parse arguments for the type BasicWithIntPositionals
[<RequireQualifiedAccess ; CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>] [<RequireQualifiedAccess ; CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module BasicWithIntPositionals = module BasicWithIntPositionals =
type private ParseState_BasicWithIntPositionals = type internal ParseState_BasicWithIntPositionals =
/// Ready to consume a key or positional arg /// Ready to consume a key or positional arg
| AwaitingKey | AwaitingKey
/// Waiting to receive a value for the key we've already consumed /// Waiting to receive a value for the key we've already consumed
| AwaitingValue of key : string | AwaitingValue of key : string
let parse' (getEnvironmentVariable : string -> string) (args : string list) : BasicWithIntPositionals = let parse' (getEnvironmentVariable : string -> string) (args : string list) : BasicWithIntPositionals =
let inProgress =
ArgParseHelpers_ConsumePlugin.BasicWithIntPositionals_InProgress._Empty ()
failwith "todo" failwith "todo"
let parse (args : string list) : BasicWithIntPositionals = let parse (args : string list) : BasicWithIntPositionals =
parse' System.Environment.GetEnvironmentVariable args parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open ArgParserHelpers
open System open System
open System.IO open System.IO
open WoofWare.Myriad.Plugins open WoofWare.Myriad.Plugins
@@ -1436,18 +1652,21 @@ open WoofWare.Myriad.Plugins
/// Methods to parse arguments for the type Basic /// Methods to parse arguments for the type Basic
[<RequireQualifiedAccess ; CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>] [<RequireQualifiedAccess ; CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module Basic = module Basic =
type private ParseState_Basic = type internal ParseState_Basic =
/// Ready to consume a key or positional arg /// Ready to consume a key or positional arg
| AwaitingKey | AwaitingKey
/// Waiting to receive a value for the key we've already consumed /// Waiting to receive a value for the key we've already consumed
| AwaitingValue of key : string | AwaitingValue of key : string
let parse' (getEnvironmentVariable : string -> string) (args : string list) : Basic = failwith "todo" let parse' (getEnvironmentVariable : string -> string) (args : string list) : Basic =
let inProgress = ArgParseHelpers_ConsumePlugin.Basic_InProgress._Empty ()
failwith "todo"
let parse (args : string list) : Basic = let parse (args : string list) : Basic =
parse' System.Environment.GetEnvironmentVariable args parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open ArgParserHelpers
open System open System
open System.IO open System.IO
open WoofWare.Myriad.Plugins open WoofWare.Myriad.Plugins
@@ -1455,13 +1674,17 @@ open WoofWare.Myriad.Plugins
/// Methods to parse arguments for the type BasicNoPositionals /// Methods to parse arguments for the type BasicNoPositionals
[<RequireQualifiedAccess ; CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>] [<RequireQualifiedAccess ; CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module BasicNoPositionals = module BasicNoPositionals =
type private ParseState_BasicNoPositionals = type internal ParseState_BasicNoPositionals =
/// Ready to consume a key or positional arg /// Ready to consume a key or positional arg
| AwaitingKey | AwaitingKey
/// Waiting to receive a value for the key we've already consumed /// Waiting to receive a value for the key we've already consumed
| AwaitingValue of key : string | AwaitingValue of key : string
let parse' (getEnvironmentVariable : string -> string) (args : string list) : BasicNoPositionals = failwith "todo" let parse' (getEnvironmentVariable : string -> string) (args : string list) : BasicNoPositionals =
let inProgress =
ArgParseHelpers_ConsumePlugin.BasicNoPositionals_InProgress._Empty ()
failwith "todo"
let parse (args : string list) : BasicNoPositionals = let parse (args : string list) : BasicNoPositionals =
parse' System.Environment.GetEnvironmentVariable args parse' System.Environment.GetEnvironmentVariable args

View File

@@ -468,6 +468,7 @@ module internal ShibaGenerator =
type internal ParsedRecordStructure<'choice> = type internal ParsedRecordStructure<'choice> =
{ {
NameOfInProgressType : Ident
Original : RecordType Original : RecordType
/// Map of field name to parser for that field /// Map of field name to parser for that field
LeafNodes : Map<string, LeafData<'choice>> LeafNodes : Map<string, LeafData<'choice>>
@@ -487,22 +488,22 @@ module internal ShibaGenerator =
record.LeafNodes record.LeafNodes
|> Map.toSeq |> Map.toSeq
|> Seq.map (fun (ident, data) -> |> Seq.map (fun (ident, data) ->
match data.Acc with let ty, mutability =
| Accumulation.Choice choice -> SynType.option data.TypeAfterParse match data.Acc with
| Accumulation.ChoicePositional choice -> failwith "TODO" | Accumulation.Choice _ -> SynType.option data.TypeAfterParse, true
| Accumulation.List acc -> | Accumulation.ChoicePositional _ -> failwith "TODO"
SynType.app' (SynType.createLongIdent' [ "ResizeArray" ]) [ data.TypeAfterParse ] | Accumulation.List acc ->
| Accumulation.Optional -> SynType.option data.TypeAfterParse SynType.app' (SynType.createLongIdent' [ "ResizeArray" ]) [ data.TypeAfterParse ], false
| Accumulation.Required -> SynType.option data.TypeAfterParse | Accumulation.Optional -> SynType.option data.TypeAfterParse, true
| Accumulation.Required -> SynType.option data.TypeAfterParse, true
|> fun ty -> {
{ Attrs = []
Attrs = [] Type = ty
Type = ty Ident = Some (Ident.create ident)
Ident = Some (Ident.create ident) }
}
|> SynField.make |> SynField.make
|> SynField.withMutability true |> SynField.withMutability mutability
) )
|> Seq.toList |> Seq.toList
@@ -519,7 +520,7 @@ module internal ShibaGenerator =
{ {
Attrs = [] Attrs = []
Ident = Ident.create ident |> Some Ident = Ident.create ident |> Some
Type = SynType.createLongIdent [ Ident.create $"%s{data.Original.Name.idText}_InProgress" ] Type = SynType.createLongIdent [ data.NameOfInProgressType ]
} }
|> SynField.make |> SynField.make
) )
@@ -539,7 +540,7 @@ module internal ShibaGenerator =
else else
l |> List.map (SynField.withMutability true) l |> List.map (SynField.withMutability true)
let members = let assembleMethod =
// for each field `FieldName` in order, we've made a variable `arg%i` // for each field `FieldName` in order, we've made a variable `arg%i`
// which has done the optionality check // which has done the optionality check
let instantiation = let instantiation =
@@ -783,18 +784,44 @@ module internal ShibaGenerator =
SynType.list SynType.string SynType.list SynType.string
] ]
) )
|> SynMemberDefn.memberImplementation
let emptyConstructor =
[
for KeyValue (nodeName, leaf) in record.LeafNodes do
let rhs =
match leaf.Acc with
| Accumulation.Required
| Accumulation.Optional
| Accumulation.Choice _ -> SynExpr.createIdent "None"
| Accumulation.ChoicePositional _ -> failwith "todo"
| Accumulation.List acc ->
SynExpr.applyFunction (SynExpr.createIdent "ResizeArray") (SynExpr.CreateConst ())
yield SynLongIdent.create [ Ident.create nodeName ], rhs
for KeyValue (nodeName, subRecord) in record.Records do
yield
SynLongIdent.create [ Ident.create nodeName ],
SynExpr.callMethod "_Empty" (SynExpr.createIdent' subRecord.NameOfInProgressType)
for KeyValue (nodeName, subUnion) in record.Unions do
yield SynLongIdent.create [ Ident.create nodeName ], failwith "TODO"
]
|> SynExpr.createRecord None
|> SynBinding.basic [ Ident.create "_Empty" ] [ SynPat.unit ]
|> SynBinding.withReturnAnnotation (SynType.createLongIdent [ record.NameOfInProgressType ])
|> SynMemberDefn.staticMember
{ {
Name = record.Original.Name.idText + "_InProgress" |> Ident.create Name = record.NameOfInProgressType
Fields = fields Fields = fields
Members = members |> SynMemberDefn.memberImplementation |> List.singleton |> Some Members = [ assembleMethod ; emptyConstructor ] |> Some
XmlDoc = PreXmlDoc.create $"A partially-parsed %s{record.Original.Name.idText}." |> Some XmlDoc = PreXmlDoc.create $"A partially-parsed %s{record.Original.Name.idText}." |> Some
Generics = Generics =
match record.Original.Generics with match record.Original.Generics with
| None -> None | None -> None
| Some _ -> | Some _ ->
failwith $"Record type %s{record.Original.Name.idText} had generics, which we don't support." failwith $"Record type %s{record.Original.Name.idText} had generics, which we don't support."
TypeAccessibility = Some (SynAccess.Private range0) TypeAccessibility = Some (SynAccess.Internal range0)
ImplAccessibility = None ImplAccessibility = None
Attributes = [] Attributes = []
} }
@@ -867,6 +894,7 @@ module internal ShibaGenerator =
| None -> None | None -> None
| Some (leaf, records, unions) -> | Some (leaf, records, unions) ->
{ {
NameOfInProgressType = rt.Name.idText + "_InProgress" |> Ident.create
Original = rt Original = rt
LeafNodes = leaf |> Map.ofList LeafNodes = leaf |> Map.ofList
Records = records |> Map.ofList Records = records |> Map.ofList
@@ -1034,14 +1062,16 @@ module internal ShibaGenerator =
DatalessUnions = Map.ofList datalessUnions DatalessUnions = Map.ofList datalessUnions
} }
let helperModuleName (namespaceName : LongIdent) : Ident =
let ns = namespaceName |> List.map _.idText |> String.concat "_"
Ident.create $"ArgParseHelpers_%s{ns}"
let createHelpersModule (opens : SynOpenDeclTarget list) (ns : LongIdent) (info : AllInfo) : SynModuleDecl = let createHelpersModule (opens : SynOpenDeclTarget list) (ns : LongIdent) (info : AllInfo) : SynModuleDecl =
let modName = let modName = helperModuleName ns
let ns = ns |> List.map _.idText |> String.concat "_"
Ident.create $"ArgParseHelpers_%s{ns}"
let modInfo = let modInfo =
SynComponentInfo.create modName SynComponentInfo.create modName
|> SynComponentInfo.withAccessibility (SynAccess.Private range0) |> SynComponentInfo.withAccessibility (SynAccess.Internal range0)
|> SynComponentInfo.withDocString (PreXmlDoc.create $"Helper types for arg parsing") |> SynComponentInfo.withDocString (PreXmlDoc.create $"Helper types for arg parsing")
let flagDuNames = info.FlagDus.Keys let flagDuNames = info.FlagDus.Keys
@@ -1073,8 +1103,8 @@ module internal ShibaGenerator =
(opens : SynOpenDeclTarget list) (opens : SynOpenDeclTarget list)
(ns : LongIdent) (ns : LongIdent)
((taggedType : SynTypeDefn, spec : ArgParserOutputSpec)) ((taggedType : SynTypeDefn, spec : ArgParserOutputSpec))
(allUnionTypes : UnionType list) (helperModName : LongIdent)
(allRecordTypes : RecordType list) (structures : AllInfo)
: SynModuleOrNamespace : SynModuleOrNamespace
= =
let taggedType = let taggedType =
@@ -1087,6 +1117,8 @@ module internal ShibaGenerator =
_) -> RecordType.OfRecord sci smd access fields _) -> RecordType.OfRecord sci smd access fields
| _ -> failwith "[<ArgParser>] currently only supports being placed on records." | _ -> failwith "[<ArgParser>] currently only supports being placed on records."
let taggedTypeInfo = structures.RecordParsers.[taggedType.Name.idText]
let modAttrs, modName = let modAttrs, modName =
if spec.ExtensionMethods then if spec.ExtensionMethods then
[ SynAttribute.autoOpen ], Ident.create (taggedType.Name.idText + "ArgParse") [ SynAttribute.autoOpen ], Ident.create (taggedType.Name.idText + "ArgParse")
@@ -1131,7 +1163,7 @@ module internal ShibaGenerator =
|> SynTypeDefnRepr.union |> SynTypeDefnRepr.union
|> SynTypeDefn.create ( |> SynTypeDefn.create (
SynComponentInfo.create parseStateIdent SynComponentInfo.create parseStateIdent
|> SynComponentInfo.setAccessibility (Some (SynAccess.Private range0)) |> SynComponentInfo.setAccessibility (Some (SynAccess.Internal range0))
) )
|> List.singleton |> List.singleton
|> SynModuleDecl.createTypes |> SynModuleDecl.createTypes
@@ -1144,6 +1176,17 @@ module internal ShibaGenerator =
let parsePrime = let parsePrime =
SynExpr.CreateConst "todo" SynExpr.CreateConst "todo"
|> SynExpr.applyFunction (SynExpr.createIdent "failwith") |> SynExpr.applyFunction (SynExpr.createIdent "failwith")
|> SynExpr.createLet
[
SynBinding.basic
[ Ident.create "inProgress" ]
[]
(SynExpr.applyFunction
(SynExpr.createLongIdent' (
helperModName @ [ taggedTypeInfo.NameOfInProgressType ; Ident.create "_Empty" ]
))
(SynExpr.CreateConst ()))
]
|> SynBinding.basic |> SynBinding.basic
[ Ident.create "parse'" ] [ Ident.create "parse'" ]
[ [
@@ -1290,6 +1333,8 @@ type ShibaGenerator () =
unionsAndRecordsByNs unionsAndRecordsByNs
|> Map.map (fun _ (us, rs) -> ShibaGenerator.parseStructureWithinNs us rs) |> Map.map (fun _ (us, rs) -> ShibaGenerator.parseStructureWithinNs us rs)
let helperModNamespaceName = Ident.create "ArgParserHelpers"
let helpersMod = let helpersMod =
structuresWithinNs structuresWithinNs
|> Map.toSeq |> Map.toSeq
@@ -1298,12 +1343,21 @@ type ShibaGenerator () =
) )
|> Seq.toList |> Seq.toList
|> fun l -> [ yield! l ] |> fun l -> [ yield! l ]
|> SynModuleOrNamespace.createNamespace [ Ident.create "ArgParserHelpers" ] |> SynModuleOrNamespace.createNamespace [ helperModNamespaceName ]
let modules = let modules =
namespaceAndTypes namespaceAndTypes
|> List.map (fun (ns, taggedType, unions, records) -> |> List.map (fun (ns, taggedType, _, _) ->
ShibaGenerator.createModule opens ns taggedType unions records let opens =
SynOpenDeclTarget.ModuleOrNamespace (SynLongIdent.create [ helperModNamespaceName ], range0)
:: opens
ShibaGenerator.createModule
opens
ns
taggedType
[ ShibaGenerator.helperModuleName ns ]
structuresWithinNs.[ns |> List.map _.idText |> String.concat "."]
) )
Output.Ast (helpersMod :: modules) Output.Ast (helpersMod :: modules)