Skip to content

Commit e07c8cc

Browse files
Make Command a trait
1 parent 915b41f commit e07c8cc

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

library/src/scala/annotation/MainAnnotation.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ trait MainAnnotation extends StaticAnnotation:
2424
def command(args: Array[String], commandName: String, docComment: String): Command
2525

2626
/** A class representing a command to run */
27-
abstract class Command(val commandName: String, val docComment: String):
27+
trait Command:
2828

2929
/** The getter for the next argument of type `T` */
3030
def argGetter[T](argName: String, argType: String, argDoc: String)(using fromString: ArgumentParser[T]): () => T

library/src/scala/main.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class main extends scala.annotation.MainAnnotation:
9191
case _ =>
9292

9393
override def command(args: Array[String], commandName: String, docComment: String): Command =
94-
new Command(commandName, docComment):
94+
new Command:
9595
/** A buffer of demanded arguments */
9696
private var argInfos = new mutable.ListBuffer[self.Argument]
9797

@@ -121,10 +121,10 @@ class main extends scala.annotation.MainAnnotation:
121121
case None => error(s"invalid argument for $argName: $arg")
122122

123123
private def usage(): Unit =
124-
self.usage(this.commandName, argInfos.toSeq)
124+
self.usage(commandName, argInfos.toSeq)
125125

126126
private def explain(): Unit =
127-
self.explain(this.commandName, this.docComment, argInfos.toSeq)
127+
self.explain(commandName, docComment, argInfos.toSeq)
128128

129129
private def indicesOfArg(argName: String): Seq[Int] =
130130
def allIndicesOf(s: String): Seq[Int] =

0 commit comments

Comments
 (0)