@@ -46,39 +46,82 @@ module Usage =
4646 val complete : Usage -> string -> string list * bool
4747
4848
49+ val req : Usages -> Usages
50+
51+ module Short =
52+ val ofString : string -> string option
53+
54+
4955
5056
5157[<AutoOpen>]
5258module Fargo =
53- /// parse the command line arguments with the specifier arg parser and pass
54- /// parsed result to the suppied function
59+ /// A command parser. Commands have specified name or alt, and are always matched as the first token
5560 val cmd : name : string -> alt : string -> description : string -> Arg < string >
61+
62+ /// An option parser with a completer. Options are matched by name and are optional by default.
5663 val optc : name : string -> alt : string -> value : string -> description : string -> completer : Completer -> Arg < string option >
64+ /// An option parser. Options are specified by name and are optional by default.
5765 val opt : name : string -> alt : string -> value : string -> description : string -> Arg < string option >
5866
67+ /// Make an option required
5968 val reqOpt : arg : Arg < 'a option > -> Arg < 'a >
6069
70+ /// An argument parser with a completer. Arguments is position based and is optional by default
6171 val argc : value : string -> description : string -> completer : Completer -> Arg < string option >
72+
73+ /// An argument parser. Arguments is position based and is optional by default
6274 val arg : value : string -> description : string -> Arg < string option >
6375
76+ /// Make an argument required
6477 val reqArg : Arg < 'a option > -> Arg < 'a >
78+
79+ /// A flag parser. Flags are matched by name and are optional by default. Value is false when not specified
6580 val flag : string -> string -> string -> Arg < bool >
6681
82+ /// Make a flag required.
6783 val reqFlag : Arg < bool > -> Arg < bool >
6884
85+ /// Parse an arg value. If value parsing fails, the argument parsing stops with specified error message.
6986 val parse : ( 'a -> Result < 'b , string >) -> Arg < 'a > -> Arg < 'b >
87+
88+ /// Parse an arg optional value. If value parsing fails, the argument parsing stops with specified error message.
7089 val optParse : ( 'a -> Result < 'b , string >) -> Arg < 'a option > -> Arg < 'b option >
90+
91+ /// Parse all elements of a list argument. The parsing fails if any value parsing fails.
7192 val listParse : ( 'a -> Result < 'b , string >) -> Arg < 'a list > -> Arg < 'b list >
7293
94+ /// An argument containing all the remaining tokens.
95+ val all : value : string -> description : string -> Arg < Tokens >
96+
97+
98+ /// Validates argument value. If validation fails, error message is used.
99+ val validate : f :( 'a -> bool ) -> error : string -> arg : Arg < 'a > -> Arg < 'a >
100+
101+ /// Validates argument value. If validation fails, error message is used.
102+ val optValidate : f :( 'a -> bool ) -> error : string -> arg : Arg < 'a option > -> Arg < 'a option >
103+
104+ /// Validates that the argument list value is not empty.
73105 val nonEmpty : string -> Arg < 'a list > -> Arg < 'a list >
74106
107+ /// Converts an argument value using specified function
75108 val map : ( 'a -> 'b ) -> Arg < 'a > -> Arg < 'b >
109+ /// Converts an optional argument value using specified function
76110 val optMap : ( 'a -> 'b ) -> Arg < 'a option > -> Arg < 'b option >
111+
112+ /// Use specified value for optional argument when argument is missing.
77113 val defaultValue : 'a -> Arg < 'a option > -> Arg < 'a >
114+
115+ /// Combines two arguments values using specified function.
78116 val map2 : ( 'a -> 'b -> 'c ) -> Arg < 'a > -> Arg < 'b > -> Arg < 'c >
117+
118+ /// Returns new parser depending on an argument (usually a cmd) value.
79119 val bind : ( 'a -> Arg < 'b >) -> Arg < 'a > -> Arg < 'b >
120+
121+ /// Creates an arguments that has the given value.
80122 val ret : 'a -> Arg < 'a >
81123
124+ /// The builder for the fargo Computation Expression.
82125 [<Class>]
83126 type FargoBuilder =
84127 member Bind : Arg < 'a > * ( 'a -> Arg < 'b >) -> Arg < 'b >
@@ -88,32 +131,60 @@ module Fargo =
88131 member ReturnFrom : Arg < 'a > -> Arg < 'a >
89132 member Zero : unit -> Arg < unit >
90133
134+ /// The fargo Computation Expression.
91135 val fargo : FargoBuilder
92136
93- val alt : Arg < 'a > -> Arg < 'a > -> Arg < 'a >
137+ /// Returns x value if parsing succeeds , otherwhite return y value.
138+ val alt : y : Arg < 'a > -> x : Arg < 'a > -> Arg < 'a >
139+ /// Returns x value if parsing succeeds and has a value , otherwhite return y value.
94140 val optAlt : Arg < 'a option > -> Arg < 'a option > -> Arg < 'a option >
141+
142+ /// Creates an argument that always returns given error message
95143 val error : message : string -> Arg < 'a >
144+
145+ /// Creates an argument that always returns given error message
146+ val errors : messages : string list -> Arg < 'a >
147+
148+
149+
150+ /// Creates an argument that returns a error message depending on remaining tokens.
96151 val errorf < 'a > : messageFunc :( Token list -> string ) -> Arg < 'a >
97152
153+ /// Creates an arg that returns a error message indicating an unknown cmd.
98154 val cmdError < 'a > : Arg < 'a >
99155
156+ /// Add specific help message to specified argument.
100157 val help : text : string -> arg : Arg < 't > -> Arg < 't >
101158
102159module Operators =
160+ /// Take value on the left, or the value on the right.
103161 val (<|>) : Arg < 'a > -> Arg < 'a > -> Arg < 'a >
162+ /// Take value on the left, or the value on the right.
104163 val (<|?>) : Arg < 'a option > -> Arg < 'a option > -> Arg < 'a option >
164+ /// Change the value of an argument with the specified constant.
105165 val (|>>) : Arg < 'a > -> 'b -> Arg < 'b >
106166
107167
108168[<AutoOpen>]
109169module Run =
170+ val toResult : arg : Arg < 'a > -> Arg < ParseResult < 'a > * Usages >
171+
110172 val tryParseTokens : arg : Arg < 'a > -> tokens : Tokens -> Result < 'a , string list * Usages >
111173 val complete : Arg < 'a > -> int -> Tokens -> string list
112174
113175
176+ val printErrors : string seq -> unit
114177 val printUsage : Usages -> unit
178+ val printDescription : Usages -> unit
179+ val printOptions : Usage list -> unit
115180 val printHelp : Usages -> unit
116181
182+ type Shell = Powershell
183+
184+ val printCompletion : appName : string -> shell : Shell -> unit
185+
186+ val getUsages : arg : Arg < 'a > -> Arg < Result < 'a , string list > * Usages >
187+
117188 /// parse the command line arguments with the specifier arg parser and pass
118189 /// parsed result to the suppied function
119190 val run : appName : string -> arg : Arg < 'a > -> cmdLine : string [] -> f :( Threading.CancellationToken -> 'a -> Threading.Tasks.Task < int >) -> int
0 commit comments