-
-
Notifications
You must be signed in to change notification settings - Fork 331
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added --import command-line option (#1526)
With this PR applied, you can run targets from external modules from the command-line without touching the `build.sc`. Example: ``` dev-mill --plugin ivy:de.tototec::de.tobiasroeser.mill.vcs.version_mill0.10.0-M2:0.1.2 show de.tobiasroeser.mill.vcs.version.VcsVersion/vcsState ``` This PR also add support for empty versions in $ivy-imports, which will get expanded to the exact mill version. This makes consuming mill contrib plugins even more easy. Example: Generating Bloop Config without modifying the `build.sc` ``` mill --plugin ivy:com.lihaoyi::mill-contrib-bloop: mill.contrib.bloop.Bloop/install ``` Pull request: #1526
- Loading branch information
Showing
7 changed files
with
211 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package mill | ||
|
||
import mainargs.{Flag, Leftover, arg} | ||
|
||
case class MillConfig( | ||
ammoniteCore: ammonite.main.Config.Core, | ||
@arg( | ||
short = 'h', | ||
doc = | ||
"The home directory of the REPL; where it looks for config and caches" | ||
) | ||
home: os.Path = mill.api.Ctx.defaultHome, | ||
@arg( | ||
doc = | ||
"""Run Mill in interactive mode and start a build REPL. In this mode, no | ||
mill server will be used. Must be the first argument.""" | ||
) | ||
repl: Flag, | ||
@arg( | ||
name = "no-server", | ||
doc = | ||
"""Run Mill in interactive mode, suitable for opening REPLs and taking user | ||
input. In this mode, no mill server will be used. Must be the first argument.""" | ||
) | ||
noServer: Flag, | ||
@arg( | ||
short = 'i', | ||
doc = | ||
"""Run Mill in interactive mode, suitable for opening REPLs and taking user | ||
input. In this mode, no mill server will be used. Must be the first argument.""" | ||
) | ||
interactive: Flag, | ||
@arg(name = "version", short = 'v', doc = "Show mill version and exit.") | ||
showVersion: Flag, | ||
@arg( | ||
name = "bell", | ||
short = 'b', | ||
doc = | ||
"Ring the bell once if the run completes successfully, twice if it fails." | ||
) | ||
ringBell: Flag, | ||
@arg( | ||
name = "disable-ticker", | ||
doc = | ||
"Disable ticker log (e.g. short-lived prints of stages and progress bars)" | ||
) | ||
disableTicker: Flag, | ||
@arg(name = "debug", short = 'd', doc = "Show debug output on STDOUT") | ||
debugLog: Flag, | ||
@arg( | ||
name = "keep-going", | ||
short = 'k', | ||
doc = "Continue build, even after build failures" | ||
) | ||
keepGoing: Flag, | ||
@arg( | ||
name = "define", | ||
short = 'D', | ||
doc = "Define (or overwrite) a system property" | ||
) | ||
extraSystemProperties: Map[String, String], | ||
@arg( | ||
name = "jobs", | ||
short = 'j', | ||
doc = | ||
"""Allow processing N targets in parallel. Use 1 to disable parallel and 0 to | ||
use as much threads as available processors.""" | ||
) | ||
threadCountRaw: Option[Int], | ||
@arg( | ||
name = "import", | ||
doc = """Additional ivy dependencies to load into mill, e.g. plugins.""" | ||
) | ||
imports: Seq[String], | ||
@arg( | ||
name = "rest", | ||
doc = | ||
"""The name of the targets you want to build, followed by any parameters | ||
you wish to pass to those targets.""" | ||
) | ||
leftoverArgs: Leftover[String] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package mill | ||
|
||
import mainargs.ParserForClass | ||
import ammonite.repl.tools.Util.PathRead | ||
|
||
object MillConfigParser { | ||
|
||
val customName = s"Mill Build Tool, version ${BuildInfo.millVersion}" | ||
val customDoc = "usage: mill [options] [[target [target-options]] [+ [target ...]]]" | ||
|
||
private[this] lazy val parser: ParserForClass[MillConfig] = mainargs.ParserForClass[MillConfig] | ||
|
||
lazy val usageText = parser.helpText(customName = customName, customDoc = customDoc) | ||
|
||
def parse(args: Array[String]): Either[String, MillConfig] = { | ||
parser.constructEither( | ||
args, | ||
allowRepeats = true, | ||
autoPrintHelpAndExit = None, | ||
customName = customName, | ||
customDoc = customDoc | ||
) | ||
.map { config => | ||
config.copy( | ||
ammoniteCore = config.ammoniteCore.copy(home = config.home) | ||
) | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.