1
1
package scala .util
2
2
3
+ import language .experimental .captureChecking
4
+
3
5
/** A utility object to support command line parsing for @main methods */
4
6
object CommandLineParser {
5
7
@@ -12,7 +14,7 @@ object CommandLineParser {
12
14
/** Parse command line argument `s`, which has index `n`, as a value of type `T`
13
15
* @throws ParseError if argument cannot be converted to type `T`.
14
16
*/
15
- def parseString [T ](str : String , n : Int )(using fs : FromString [T ]): T = {
17
+ def parseString [T ](str : String , n : Int )(using fs : FromString [T ]^ ): T = {
16
18
try fs.fromString(str)
17
19
catch {
18
20
case ex : IllegalArgumentException => throw ParseError (n, ex.toString)
@@ -22,14 +24,14 @@ object CommandLineParser {
22
24
/** Parse `n`'th argument in `args` (counting from 0) as a value of type `T`
23
25
* @throws ParseError if argument does not exist or cannot be converted to type `T`.
24
26
*/
25
- def parseArgument [T ](args : Array [String ], n : Int )(using fs : FromString [T ]): T =
27
+ def parseArgument [T ](args : Array [String ], n : Int )(using fs : FromString [T ]^ ): T =
26
28
if n < args.length then parseString(args(n), n)
27
29
else throw ParseError (n, " more arguments expected" )
28
30
29
31
/** Parse all arguments from `n`'th one (counting from 0) as a list of values of type `T`
30
32
* @throws ParseError if some of the arguments cannot be converted to type `T`.
31
33
*/
32
- def parseRemainingArguments [T ](args : Array [String ], n : Int )(using fs : FromString [T ]): List [T ] =
34
+ def parseRemainingArguments [T ](args : Array [String ], n : Int )(using fs : FromString [T ]^ ): List [T ] =
33
35
if n < args.length then parseString(args(n), n) :: parseRemainingArguments(args, n + 1 )
34
36
else Nil
35
37
0 commit comments