Small library allowing to provide annotation based help text for functions in the Scala REPL. Easily implement a help method in your REPL application by writing help texts into method annotations.
In order to use the REPL helper, you can add it as a dependency to your project using JitPack.io. Just add it to your build.sbt
like this:
resolvers += "jitpack" at "https://jitpack.io"
libraryDependencies += "com.github.FRosner" % "repl-helper" % "x.y.z"
-
Define the
@Help
annotation on your methods.object MyReplUtil { @Help( category = "Math", shortDescription = "Add two numbers", longDescription = "Add two numbers. Integer overflow might occur!", parameters = "a: Int, b: Int" ) def add(a: Int, b: Int) = a + b }
-
Create a helper instance of your class.
val myHelper = Helper(MyReplUtil.getClass)
-
Print help to a
PrintStream
of your choice. You can either print all available methods or request detailed help for a particular one.myHelper.printAllMethods(System.out) myHelper.printMethods("add", System.out)