@@ -26,6 +26,7 @@ type HandlerInput<'T>(inputType: HandlerInputSource) =
2626 static member OfOption < 'T >( o : Option < 'T >) = o :> Option |> ParsedOption |> HandlerInput< 'T>
2727 static member OfArgument < 'T >( a : Argument < 'T >) = a :> Argument |> ParsedArgument |> HandlerInput< 'T>
2828
29+
2930/// Creates CLI options and arguments to be passed as command ` inputs ` .
3031type Input =
3132
@@ -44,7 +45,7 @@ type Input =
4445 description = ( description |> Option.defaultValue null )
4546 )
4647 |> HandlerInput.OfOption
47-
48+
4849 /// Creates a CLI option of type 'T with a default value.
4950 static member Option < 'T >( name : string , defaultValue : 'T , ? description : string ) =
5051 Option< 'T>(
@@ -63,6 +64,24 @@ type Input =
6364 )
6465 |> HandlerInput.OfOption
6566
67+ /// Creates a CLI option of type 'T that is required.
68+ static member OptionRequired < 'T >( name : string , ? description : string ) =
69+ Option< 'T>(
70+ name,
71+ description = ( description |> Option.defaultValue null ),
72+ IsRequired = true
73+ )
74+ |> HandlerInput.OfOption
75+
76+ /// Creates a CLI option of type 'T that is required.
77+ static member OptionRequired < 'T >( aliases : string seq , ? description : string ) =
78+ Option< 'T>(
79+ aliases |> Seq.toArray,
80+ description = ( description |> Option.defaultValue null ),
81+ IsRequired = true
82+ )
83+ |> HandlerInput.OfOption
84+
6685 /// Creates a CLI option of type 'T option.
6786 static member OptionMaybe < 'T >( name : string , ? description : string ) =
6887 Option< 'T option>(
@@ -86,7 +105,7 @@ type Input =
86105 | None -> failwith " F# Option can only be used with a single argument."
87106 ),
88107 description = ( description |> Option.defaultValue null )
89- )
108+ )
90109 |> HandlerInput.OfOption
91110
92111 /// Creates a CLI argument of type 'T.
@@ -103,7 +122,7 @@ type Input =
103122 name,
104123 getDefaultValue = ( fun () -> defaultValue),
105124 description = ( description |> Option.defaultValue null )
106- )
125+ )
107126 |> HandlerInput.OfArgument
108127
109128 /// Creates a CLI argument of type 'T option.
0 commit comments