summaryrefslogtreecommitdiff
path: root/docs/examples/plugintemplate/src/plugintemplate/standalone/Main.scala
diff options
context:
space:
mode:
Diffstat (limited to 'docs/examples/plugintemplate/src/plugintemplate/standalone/Main.scala')
-rw-r--r--docs/examples/plugintemplate/src/plugintemplate/standalone/Main.scala38
1 files changed, 38 insertions, 0 deletions
diff --git a/docs/examples/plugintemplate/src/plugintemplate/standalone/Main.scala b/docs/examples/plugintemplate/src/plugintemplate/standalone/Main.scala
new file mode 100644
index 0000000000..6eec249ed7
--- /dev/null
+++ b/docs/examples/plugintemplate/src/plugintemplate/standalone/Main.scala
@@ -0,0 +1,38 @@
+package plugintemplate.standalone
+
+import scala.tools.nsc.CompilerCommand
+import scala.tools.nsc.Settings
+
+/** An object for running the plugin as standalone application.
+ */
+object Main {
+ def main(args: Array[String]) {
+ val settings = new Settings
+
+ val command = new CompilerCommand(args.toList, settings, println, false) {
+ /** The command name that will be printed in in the usage message.
+ * This is autmatically set to the value of 'plugin.commandname' in the
+ * file build.properties.
+ */
+ override val cmdName = PluginProperties.pluginCommand
+ }
+
+ if (!command.ok)
+ return()
+
+ /** The version number of this plugin is read from the porperties file
+ */
+ if (settings.version.value) {
+ println(command.cmdName +" version "+ PluginProperties.versionString)
+ return()
+ }
+ if (settings.help.value) {
+ println(command.usageMsg)
+ return()
+ }
+
+ val runner = new PluginRunner(settings)
+ val run = new runner.Run
+ run.compile(command.files)
+ }
+}