diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-01-07 19:11:54 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2018-01-07 19:11:54 -0800 |
commit | c5638405269326b7eb2fc0506131255ef4237750 (patch) | |
tree | 55663370c14f1d848d3f7be6e870f777dee16e03 /core/src/main/scala | |
parent | 4e996e20cbae77d993ed8e63aeb533ddcc5514dd (diff) | |
download | mill-c5638405269326b7eb2fc0506131255ef4237750.tar.gz mill-c5638405269326b7eb2fc0506131255ef4237750.tar.bz2 mill-c5638405269326b7eb2fc0506131255ef4237750.zip |
Get `--help` working
Diffstat (limited to 'core/src/main/scala')
-rw-r--r-- | core/src/main/scala/mill/Main.scala | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/core/src/main/scala/mill/Main.scala b/core/src/main/scala/mill/Main.scala index bac9d579..41fe6686 100644 --- a/core/src/main/scala/mill/Main.scala +++ b/core/src/main/scala/mill/Main.scala @@ -1,6 +1,8 @@ package mill +import ammonite.main.Cli.{formatBlock, genericSignature, replSignature} import ammonite.ops._ +import ammonite.util.Util object Main { case class Config(home: ammonite.ops.Path = pwd/'out/'ammonite, @@ -23,15 +25,27 @@ object Main { x } ) + val removed = Set("predef-code", "home", "no-home-predef") + val millArgSignature = (Cli.genericSignature :+ showCliArg).filter(a => !removed(a.name)) Cli.groupArgs( args.toList, - Cli.ammoniteArgSignature :+ showCliArg, - Cli.Config() + millArgSignature, + Cli.Config(remoteLogging = false) ) match{ case Left(msg) => System.err.println(msg) System.exit(1) + case Right((cliConfig, _)) if cliConfig.help => + val leftMargin = millArgSignature.map(ammonite.main.Cli.showArg(_).length).max + 2 + System.out.println( + s"""Mill Build Tool + |usage: mill [mill-options] [target [target-options]] + | + |${formatBlock(millArgSignature, leftMargin).mkString(Util.newLine)}""".stripMargin + ) + System.exit(0) case Right((cliConfig, leftoverArgs)) => + val repl = leftoverArgs.isEmpty val config = if(!repl) cliConfig |