Open
Description
Discussed in #144
Originally posted by kincsescsaba August 7, 2024
Hey there,
I'm not sure if this is an issue or more like a feature request, but when I try to place the @main
annotation of mainargs
in a trait, that is mixed into the class that contains the main method, I get a No @main methods declared
error.
I tried referencing the self type from ParserForMethods
but that did not fix the issue.
Here's how the approach looks like:
abstract class CaskMainWithArgs extends cask.Main:
self: Conf =>
private var args_ : Seq[String] = uninitialized
def args: Seq[String] = args_
override def main(argsArray: Array[String]): Unit =
if Option(args_).isEmpty then
args_ = argsArray.toSeq
ParserForMethods(self).runOrExit(argsArray)
super.main(argsArray)
trait Conf:
self: CaskMainWithArgs =>
@main
def runConfInit(@arg(name = "conf", short = 'c', doc = "Set a custom configuration file")
configFile: String) =
println("Hello from runConfInit")
Any ideas on how this behavior could be implemented?
Metadata
Metadata
Assignees
Labels
No labels