@@ -4,13 +4,14 @@ module FSharp.SystemCommandLine.Inputs
44open System
55open System.CommandLine
66
7- module private Parser =
7+ module private MaybeParser =
88 /// Parses an argument token value.
99 /// TODO: Ideally, this should use the S.CL Arugment parser.
1010 let parseTokenValue < 'T > ( tokenValue : string ) =
1111 match typeof< 'T> with
12- | t when t = typeof< IO.DirectoryInfo> -> IO.DirectoryInfo( tokenValue) |> box :?> 'T |> Some
13- | t when t = typeof< IO.FileInfo> -> IO.FileInfo( tokenValue) |> box :?> 'T |> Some
12+ | t when t = typeof< IO.DirectoryInfo> -> IO.DirectoryInfo( tokenValue) |> unbox< 'T> |> Some
13+ | t when t = typeof< IO.FileInfo> -> IO.FileInfo( tokenValue) |> unbox< 'T> |> Some
14+ | t when t = typeof< Uri> -> Uri( tokenValue) |> unbox< 'T> |> Some
1415 | t -> Convert.ChangeType( tokenValue, t) :?> 'T |> Some
1516
1617type HandlerInputSource =
@@ -89,7 +90,7 @@ type Input =
8990 parseArgument = ( fun argResult ->
9091 match argResult.Tokens |> Seq.toList with
9192 | [] -> None
92- | [ token ] -> Parser .parseTokenValue token.Value
93+ | [ token ] -> MaybeParser .parseTokenValue token.Value
9394 | _ :: _ -> failwith " F# Option can only be used with a single argument."
9495 ),
9596 description = ( description |> Option.defaultValue null )
@@ -103,7 +104,7 @@ type Input =
103104 parseArgument = ( fun argResult ->
104105 match argResult.Tokens |> Seq.toList with
105106 | [] -> None
106- | [ token ] -> Parser .parseTokenValue token.Value
107+ | [ token ] -> MaybeParser .parseTokenValue token.Value
107108 | _ :: _ -> failwith " F# Option can only be used with a single argument."
108109 ),
109110 description = ( description |> Option.defaultValue null )
@@ -134,7 +135,7 @@ type Input =
134135 parse = ( fun argResult ->
135136 match argResult.Tokens |> Seq.toList with
136137 | [] -> None
137- | [ token ] -> Parser .parseTokenValue token.Value
138+ | [ token ] -> MaybeParser .parseTokenValue token.Value
138139 | _ :: _ -> failwith " F# Option can only be used with a single argument."
139140 ),
140141 description = ( description |> Option.defaultValue null ),
0 commit comments