Skip to content

Commit b9670df

Browse files
committed
Rename argGetters
1 parent 88dc4cc commit b9670df

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

tests/pos/main-method-scheme-generic.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import collection.mutable
77
* The protocol of calls from compiler-main is as follows:
88
*
99
* - create a `command` with the command line arguments,
10-
* - for each parameter of user-main, a call to `command.argGetter`,
11-
* or `command.argsGetter` if is a final varargs parameter,
10+
* - for each parameter of user-main, a call to `command.nextArgGetter`,
11+
* or `command.finalArgsGetter` if is a final varargs parameter,
1212
* - a call to `command.run` with the closure of user-main applied to all arguments.
1313
*
1414
* The wrapper class has this outline:
@@ -46,10 +46,10 @@ trait MainAnnotation extends StaticAnnotation:
4646
abstract class Command:
4747

4848
/** The getter for the next argument of type `T` */
49-
def argGetter[T](argName: String, fromString: ArgumentParser[T], defaultValue: Option[T] = None): () => T
49+
def nextArgGetter[T](argName: String, fromString: ArgumentParser[T], defaultValue: Option[T] = None): () => T
5050

5151
/** The getter for a final varargs argument of type `T*` */
52-
def argsGetter[T](argName: String, fromString: ArgumentParser[T]): () => Seq[T]
52+
def finalArgsGetter[T](argName: String, fromString: ArgumentParser[T]): () => Seq[T]
5353

5454
/** Run `program` if all arguments are valid,
5555
* or print usage information and/or error messages.
@@ -66,7 +66,7 @@ trait MainAnnotation extends StaticAnnotation:
6666
inline def wrapperName(mainName: String): String
6767

6868
/** An annotation type with which the wrapper method is decorated.
69-
* No annotation is generated of the type is left abstract.
69+
* No annotation is generated if the type is left abstract.
7070
*/
7171
type WrapperAnnotation <: Annotation
7272

@@ -115,7 +115,7 @@ class main extends MainAnnotation:
115115
case Some(t) => () => t
116116
case None => error(s"invalid argument for $argName: $arg")
117117

118-
def argGetter[T](argName: String, p: ArgumentParser[T], defaultValue: Option[T] = None): () => T =
118+
def nextArgGetter[T](argName: String, p: ArgumentParser[T], defaultValue: Option[T] = None): () => T =
119119
argInfos += ((argName, if defaultValue.isDefined then "?" else ""))
120120
val idx = args.indexOf(s"--$argName")
121121
val argOpt = if idx >= 0 then argAt(idx + 1) else nextPositionalArg()
@@ -125,7 +125,7 @@ class main extends MainAnnotation:
125125
case Some(t) => () => t
126126
case None => error(s"missing argument for $argName")
127127

128-
def argsGetter[T](argName: String, p: ArgumentParser[T]): () => Seq[T] =
128+
def finalArgsGetter[T](argName: String, p: ArgumentParser[T]): () => Seq[T] =
129129
argInfos += ((argName, "*"))
130130
def remainingArgGetters(): List[() => T] = nextPositionalArg() match
131131
case Some(arg) => convert(arg, argName, p) :: remainingArgGetters()
@@ -192,8 +192,8 @@ end myProgram
192192
object add extends main:
193193
@EntryPoint def main(args: Array[String]) =
194194
val cmd = command(args)
195-
val arg1 = cmd.argGetter[Int]("num", summon[ArgumentParser[Int]])
196-
val arg2 = cmd.argGetter[Int]("inc", summon[ArgumentParser[Int]], Some(1))
195+
val arg1 = cmd.nextArgGetter[Int]("num", summon[ArgumentParser[Int]])
196+
val arg2 = cmd.nextArgGetter[Int]("inc", summon[ArgumentParser[Int]], Some(1))
197197
cmd.run(myProgram.add(arg1(), arg2()), "add", "Adds two numbers")
198198
end add
199199

0 commit comments

Comments
 (0)