Skip to content

Commit 9fb24ff

Browse files
committed
add quiet option
1 parent 034dcaa commit 9fb24ff

4 files changed

Lines changed: 39 additions & 2 deletions

File tree

src/main/kotlin/file/CLICommand.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ enum class GlobalOptions(val optionName: String = "", val argCount: Int = 0) {
5656
setupMain.addGithubWorkflow = false
5757
}
5858
},
59+
QUIET("--quiet") {
60+
override fun runOption(setupMain: SetupMain, args: List<String>) {
61+
setupMain.quiet = true
62+
}
63+
},
5964
SCRIPT_MODE("--script-mode", 1) {
6065
override fun runOption(setupMain: SetupMain, args: List<String>) {
6166
setupMain.scriptMode = when (args[0].lowercase()) {

src/main/kotlin/file/SetupApp.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ object SetupApp {
9494
| --with-ci / --no-ci Include GitHub Actions workflow (default: no)
9595
| test [filter] Run unit tests, optionally filtered by package/function name
9696
| typecheck Typecheck the project without building a map
97+
|
98+
|Global options:
99+
| --quiet Suppress wurst output; only print errors and final result
97100
| outdated Check whether project dependencies are up to date
98101
| build <mapfile> Build the project using the given input map
99102
""".trimMargin())
@@ -149,12 +152,14 @@ object SetupApp {
149152
}
150153
setup.command == CLICommand.TEST -> {
151154
log.info("⚗️ Testing project..")
155+
if (!setup.quiet) log.info("💡 Tip: run with --quiet to suppress compiler output and only show errors (useful for AI agents).")
152156
if (InstallationManager.status != InstallationManager.InstallationStatus.NOT_INSTALLED && configData != null) {
153157
testProject(configData)
154158
}
155159
}
156160
setup.command == CLICommand.TYPECHECK -> {
157161
log.info("🔍 Typechecking project..")
162+
if (!setup.quiet) log.info("💡 Tip: run with --quiet to suppress compiler output and only show errors (useful for AI agents).")
158163
if (InstallationManager.status != InstallationManager.InstallationStatus.NOT_INSTALLED && configData != null) {
159164
typecheckProject(configData)
160165
}
@@ -320,6 +325,21 @@ object SetupApp {
320325

321326
private fun startWurstProcess(args: ArrayList<String>): Int {
322327
val pb = ProcessBuilder(args)
328+
if (setup.quiet) {
329+
pb.redirectErrorStream(true)
330+
val p = pb.start()
331+
val output = p.inputStream.bufferedReader().readLines()
332+
val exitCode = p.waitFor()
333+
val errorLines = output.filter { line ->
334+
line.contains("error", ignoreCase = true) ||
335+
line.contains("Error", ignoreCase = true) ||
336+
line.contains("warning", ignoreCase = true) ||
337+
line.contains("FAILED", ignoreCase = true) ||
338+
line.contains("Exception", ignoreCase = true)
339+
}
340+
errorLines.forEach { println(it) }
341+
return exitCode
342+
}
323343
pb.redirectOutput(Redirect.INHERIT)
324344
pb.redirectError(Redirect.INHERIT)
325345
val p = pb.start()

src/main/kotlin/file/SetupMain.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class SetupMain {
2222

2323
var noPJass = false
2424

25+
var quiet = false
26+
2527
// Generate wizard options (defaults: non-interactive, Lua, Reforged, no extras)
2628
var addAgents: Boolean = false
2729
var addGithubWorkflow: Boolean = false

templates/AGENTS.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,21 @@ to add and pull a specific Git dependency.
2525
After making Wurst changes, always run:
2626

2727
```bash
28-
grill typecheck
28+
grill typecheck --quiet
2929
```
3030

31+
The `--quiet` flag suppresses verbose compiler output and only prints errors — use it to keep context small. Without it, the compiler emits a large amount of output that wastes context window space.
32+
3133
Fix reported errors and relevant warnings before considering the task done.
3234

35+
When running tests:
36+
37+
```bash
38+
grill test --quiet
39+
```
40+
41+
Same rule applies: `--quiet` filters output to errors only and prints `✔ All tests succeeded.` on success.
42+
3343
## Project configuration (`wurst.build`)
3444

3545
`wurst.build` is a YAML file at the repository root that controls project metadata, dependencies, and map build settings. It is the source of truth for:
@@ -474,7 +484,7 @@ Hot doc comments:
474484

475485
## Common pitfalls
476486

477-
* Always run `grill typecheck` after code changes.
487+
* Always run `grill typecheck --quiet` after code changes.
478488
* Do not commit `_build/` or edit `_build/dependencies/` as source.
479489
* Wurst code must be inside `package`.
480490
* Indentation defines blocks.

0 commit comments

Comments
 (0)