Skip to content

Commit adeea8f

Browse files
authored
Clean up Mill CLI flags (#5343)
I went and marked the various "internal" flags as `hidden = true`: things like `--bsp`, `--tab-complete`, and so on aren't really intended to be used directly by users, so no need to show them in the CLI `--help` message. Others like `--no-build-lock` or `--no-wait-for-build-lock` are kind of advanced features All the internal and advanced flags no longer show in the normal `--help` output, but instead in the output of `--help-advanced` which is mentioned in the `--help` message so people can find it. Deprecated flags are no longer shown in either `--help` or `--help-advanced`, as the assumption is that only legacy scripted callsites will hit these and anyone interactive should have no reason to use them: - `--no-server` is replaced by `--no-daemon` - `--enable-ticker` and `--disable-ticker` are replaced by `--ticker true/false` - `--home` is unused - `--repl` is not supported - `--disable-callgraph` no longer works - `--disable-prompt` no longer works - `--silent` seems to have been unused for quite some time Fixes #4938 and #2158 and #1946
1 parent f8bfd48 commit adeea8f

File tree

6 files changed

+74
-93
lines changed

6 files changed

+74
-93
lines changed

integration/bsp-util/src/BspServerTestUtil.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ object BspServerTestUtil {
194194
Seq(
195195
millExecutableNoBspFile0.toString,
196196
"--bsp",
197-
"--disable-ticker",
197+
"--ticker",
198+
"false",
198199
"--color",
199200
"false",
200201
"--jobs",

runner/bsp/src/mill/bsp/BSP.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ private[mill] object BSP {
4343
argv = Seq(
4444
millPath,
4545
"--bsp",
46-
"--disable-ticker",
46+
"--ticker",
47+
"false",
4748
"--color",
4849
"false",
4950
"--jobs",

runner/daemon/src/mill/daemon/MillCliConfig.scala

Lines changed: 65 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -3,67 +3,23 @@ package mill.daemon
33
import mainargs.{Flag, Leftover, arg}
44

55
case class MillCliConfig(
6-
@deprecated("No longer used", "Mill 0.12.0")
7-
@arg(
8-
hidden = true,
9-
short = 'h',
10-
doc =
11-
"""(internal) The home directory where Mill looks for config and caches."""
12-
)
13-
home: os.Path = os.home,
14-
// We need to keep it, otherwise, a given --repl would be silently parsed as target and result in misleading error messages.
15-
// Instead, we fail programmatically when this flag is set.
16-
@deprecated("No longer supported.", "Mill 0.11.0-M8")
17-
@arg(
18-
hidden = true,
19-
doc = """This flag is no longer supported."""
20-
)
21-
repl: Flag = Flag(),
22-
@arg(
23-
hidden = true,
24-
doc = """Run without a background daemon. Must be the first argument."""
25-
)
26-
noServer: Flag = Flag(),
27-
@arg(
28-
doc = """Run without a background daemon. Must be the first argument."""
29-
)
6+
// ==================== NORMAL CLI FLAGS ====================
7+
@arg(doc = "Run without a long-lived background daemon. Must be the first argument.")
308
noDaemon: Flag = Flag(),
31-
@arg(doc = """Enable BSP server mode.""")
32-
bsp: Flag,
33-
@arg(doc = """Create mill-bsp.json with Mill details under .bsp/""")
34-
bspInstall: Flag,
35-
@arg(
36-
doc =
37-
"""Automatically reload the build when its sources change when running the BSP server (defaults to true)."""
38-
)
39-
bspWatch: Boolean = true,
409
@arg(name = "version", short = 'v', doc = "Show mill version information and exit.")
4110
showVersion: Flag = Flag(),
4211
@arg(
4312
name = "bell",
4413
short = 'b',
45-
doc = """Ring the bell once if the run completes successfully, twice if it fails."""
14+
doc = "Ring the bell once if the run completes successfully, twice if it fails."
4615
)
4716
ringBell: Flag = Flag(),
48-
@deprecated("No longer supported, use `--ticker false`", "Mill 0.12.0")
49-
@arg(
50-
hidden = true,
51-
doc =
52-
"""Disable ticker log (e.g. short-lived prints of stages and progress bars)."""
53-
)
54-
disableTicker: Flag,
5517
@arg(
5618
doc =
57-
"""Enable ticker log (e.g. short-lived prints of stages and progress bars)."""
19+
"""Enable or disable the ticker log, which provides information on running
20+
tasks and where each log line came from"""
5821
)
5922
ticker: Option[Boolean] = None,
60-
@deprecated("No longer supported, use `--ticker false`", "Mill 0.12.0")
61-
@arg(
62-
hidden = true,
63-
doc =
64-
"""Enable ticker log (e.g. short-lived prints of stages and progress bars)."""
65-
)
66-
enableTicker: Option[Boolean] = None,
6723
@arg(name = "debug", short = 'd', doc = "Show debug output on STDOUT")
6824
debugLog: Flag = Flag(),
6925
@arg(
@@ -97,61 +53,47 @@ case class MillCliConfig(
9753
short = 'i',
9854
doc =
9955
"""Run Mill in interactive mode, suitable for opening REPLs and taking user input.
100-
This implies --no-server. Must be the first argument."""
56+
Identical to --no-daemon. Must be the first argument."""
10157
)
10258
interactive: Flag = Flag(),
10359
@arg(doc = "Print this help message and exit.")
10460
help: Flag,
105-
@arg(
106-
short = 'w',
107-
doc = """Watch and re-run the given tasks when when their inputs change."""
108-
)
61+
@arg(doc = "Print a internal or advanced command flags not intended for common usage")
62+
helpAdvanced: Flag,
63+
@arg(short = 'w', doc = "Watch and re-run the given tasks when when their inputs change.")
10964
watch: Flag = Flag(),
11065
@arg(
11166
name = "notify-watch",
11267
doc = "Use filesystem based file watching instead of polling based one (defaults to true)."
11368
)
11469
watchViaFsNotify: Boolean = true,
115-
@arg(
116-
short = 's',
117-
doc =
118-
"""Make ivy logs during script import resolution go silent instead of printing"""
119-
)
120-
silent: Flag = Flag(),
121-
@arg(
122-
name = "task",
123-
doc = """The name or a pattern of the tasks(s) you want to build."""
124-
)
70+
@arg(name = "task", doc = "The name or a query of the tasks(s) you want to build.")
12571
leftoverArgs: Leftover[String] = Leftover(),
12672
@arg(doc =
127-
"""Toggle colored output; by default enabled only if the console is interactive and NO_COLOR environment variable is not set"""
73+
"""Toggle colored output; by default enabled only if the console is interactive
74+
and NO_COLOR environment variable is not set"""
12875
)
12976
color: Option[Boolean] = None,
130-
@arg(
131-
name = "disable-callgraph",
132-
doc = """
133-
Disables fine-grained invalidation of tasks based on analyzing code changes. If passed, you
134-
need to manually run `clean` yourself after build changes.
135-
"""
136-
)
137-
disableCallgraph: Flag = Flag(),
13877
@arg(
13978
doc =
14079
"""Select a meta-level to run the given tasks. Level 0 is the main project in `build.mill`,
14180
level 1 the first meta-build in `mill-build/build.mill`, etc."""
14281
)
14382
metaLevel: Option[Int] = None,
83+
84+
// ==================== ADVANCED CLI FLAGS ====================
14485
@arg(doc = "Allows command args to be passed positionally without `--arg` by default")
14586
allowPositional: Flag = Flag(),
146-
@deprecated("No longer used", "Mill 0.13.0")
87+
@arg(hidden = true, doc = """Enable BSP server mode.""")
88+
bsp: Flag,
89+
@arg(hidden = true, doc = """Create mill-bsp.json with Mill details under .bsp/""")
90+
bspInstall: Flag,
14791
@arg(
148-
doc = """
149-
Disables the new multi-line status prompt used for showing thread
150-
status at the command line and falls back to the legacy ticker
151-
""",
152-
hidden = true
92+
hidden = true,
93+
doc =
94+
"""Automatically reload the build when its sources change when running the BSP server (defaults to true)."""
15395
)
154-
disablePrompt: Flag = Flag(),
96+
bspWatch: Boolean = true,
15597
@arg(
15698
hidden = true,
15799
doc =
@@ -184,10 +126,28 @@ case class MillCliConfig(
184126
@arg(
185127
doc = """Runs Mill in tab-completion mode"""
186128
)
187-
tabComplete: Flag = Flag()
129+
tabComplete: Flag = Flag(),
130+
131+
// ==================== DEPRECATED CLI FLAGS ====================
132+
@arg(hidden = true, short = 'h', doc = "Unsupported")
133+
home: os.Path = os.home,
134+
@arg(hidden = true, doc = "Unsupported")
135+
repl: Flag = Flag(),
136+
@arg(hidden = true, doc = "Unsupported")
137+
noServer: Flag = Flag(),
138+
@arg(short = 's', doc = "Unsupported")
139+
silent: Flag = Flag(),
140+
@arg(name = "disable-callgraph", doc = "Unsupported")
141+
disableCallgraph: Flag = Flag(),
142+
@arg(hidden = true, doc = "Unsupported")
143+
disablePrompt: Flag = Flag(),
144+
@arg(hidden = true, doc = "Unsupported")
145+
enableTicker: Option[Boolean] = None,
146+
@arg(hidden = true, doc = "Unsupported")
147+
disableTicker: Flag
188148
) {
189149
def noDaemonEnabled =
190-
Seq(interactive.value, noServer.value, noDaemon.value, bsp.value).count(identity)
150+
Seq(interactive.value, noDaemon.value, noServer.value, bsp.value).count(identity)
191151
}
192152

193153
import mainargs.ParserForClass
@@ -231,8 +191,21 @@ options:
231191

232192
import mill.define.JsonFormatters.*
233193

234-
private lazy val parser: ParserForClass[MillCliConfig] =
235-
mainargs.ParserForClass[MillCliConfig]
194+
private lazy val parser: ParserForClass[MillCliConfig] = mainargs.ParserForClass[MillCliConfig]
195+
196+
private lazy val helpAdvancedParser: ParserForClass[MillCliConfig] = new ParserForClass(
197+
parser.main.copy(argSigs0 = parser.main.argSigs0.collect {
198+
case a if !a.doc.contains("Unsupported") && a.hidden =>
199+
a.copy(
200+
hidden = false,
201+
// Hack to work around `a.copy` not propagating the name mapping correctly, so we have
202+
// to manually map the name ourselves. Doesn't affect runtime behavior since this is
203+
// just used for --help-advanced printing and not for argument parsing
204+
unMappedName = a.mappedName(mainargs.Util.kebabCaseNameMapper)
205+
)
206+
}),
207+
parser.companion
208+
)
236209

237210
lazy val shortUsageText: String =
238211
"Please specify a task to evaluate\n" +
@@ -244,7 +217,14 @@ options:
244217
customDoc +
245218
cheatSheet +
246219
parser.helpText(customName = "", totalWidth = 100).stripPrefix("\n") +
247-
"\nPlease see the documentation at https://mill-build.org for more details"
220+
"\nPlease see the documentation at https://mill-build.org for more details,\n" +
221+
"or `./mill --help-advanced` for a list of advanced flags"
222+
223+
lazy val helpAdvancedUsageText: String =
224+
customName +
225+
customDoc +
226+
helpAdvancedParser.helpText(customName = "", totalWidth = 100).stripPrefix("\n") +
227+
"\nAdvanced or internal command-line flags not intended for common usage. Use at your own risk!"
248228

249229
def parse(args: Array[String]): mill.api.Result[MillCliConfig] = {
250230
mill.api.Result.fromEither(parser.constructEither(

runner/daemon/src/mill/daemon/MillMain0.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,7 @@ object MillMain0 {
157157
val colors =
158158
if (colored) mill.internal.Colors.Default else mill.internal.Colors.BlackWhite
159159

160-
if (!config.silent.value) {
161-
checkMillVersionFromFile(BuildCtx.workspaceRoot, streams.err)
162-
}
160+
checkMillVersionFromFile(BuildCtx.workspaceRoot, streams.err)
163161

164162
val maybeThreadCount =
165163
parseThreadCount(config.threadCountRaw, Runtime.getRuntime.availableProcessors())

testkit/src/mill/testkit/ExampleTester.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ class ExampleTester(
107107
check: Boolean = true
108108
): Unit = {
109109
val commandStr = commandStr0 match {
110-
case s"mill $rest" => s"./mill$millExt $daemonFlag --disable-ticker $rest"
111-
case s"./mill $rest" => s"./mill$millExt $daemonFlag --disable-ticker $rest"
110+
case s"mill $rest" => s"./mill$millExt $daemonFlag --ticker false $rest"
111+
case s"./mill $rest" => s"./mill$millExt $daemonFlag --ticker false $rest"
112112
case s"curl $rest" => s"curl --retry 7 --retry-all-errors $rest"
113113
case s => s
114114
}

testkit/src/mill/testkit/IntegrationTester.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ object IntegrationTester {
7373

7474
val debugArgs = Option.when(debugLog)("--debug")
7575

76-
val shellable: os.Shellable = (millExecutable, serverArgs, "--disable-ticker", debugArgs, cmd)
76+
val shellable: os.Shellable =
77+
(millExecutable, serverArgs, "--ticker", "false", debugArgs, cmd)
7778

7879
val res0 = os.call(
7980
cmd = shellable,

0 commit comments

Comments
 (0)