Skip to content

Commit 24a3ab9

Browse files
authored
Merge pull request #12 from webcoyote/add-quiet-flag
Add -q/--quiet flag to suppress output on success
2 parents 52c2e45 + 8c8047c commit 24a3ab9

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

CLAUDE.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ swift test 2>&1 | xcsift
4141
# Print detailed warnings list (by default only warning count is shown in summary)
4242
swift build 2>&1 | xcsift --print-warnings
4343
xcodebuild build 2>&1 | xcsift --print-warnings
44+
45+
# Quiet mode - suppress output when build succeeds with no warnings or errors
46+
swift build 2>&1 | xcsift --quiet
47+
xcodebuild build 2>&1 | xcsift -q
4448
```
4549

4650
## Architecture
@@ -99,4 +103,5 @@ The tool outputs structured data optimized for coding agents:
99103
- **JSON**: Structured format with `status`, `summary`, `errors`, `warnings` (optional), `failed_tests`
100104
- **Summary always includes warning count**: `{"summary": {"warnings": N, ...}}`
101105
- **Detailed warnings list** (with `--print-warnings` flag): `{"warnings": [{"file": "...", "line": N, "message": "..."}]}`
102-
- **Default behavior** (without flag): Only shows warning count in summary, omits detailed warnings array to reduce token usage
106+
- **Default behavior** (without flag): Only shows warning count in summary, omits detailed warnings array to reduce token usage
107+
- **Quiet mode** (with `--quiet` or `-q` flag): Produces no output when build succeeds with zero warnings and zero errors

Sources/main.swift

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct XCSift: ParsableCommand {
1515
static let configuration = CommandConfiguration(
1616
commandName: "xcsift",
1717
abstract: "A Swift tool to parse and format xcodebuild output for coding agents",
18-
usage: "xcodebuild [options] 2>&1 | xcsift [--warnings|-w] [--version|-v] [--help|-h]",
18+
usage: "xcodebuild [options] 2>&1 | xcsift [--warnings|-w] [--quiet|-q] [--version|-v] [--help|-h]",
1919
discussion: """
2020
xcsift reads xcodebuild output from stdin and outputs structured JSON.
2121
@@ -27,6 +27,7 @@ struct XCSift: ParsableCommand {
2727
xcodebuild test 2>&1 | xcsift -w
2828
swift build 2>&1 | xcsift --warnings
2929
swift test 2>&1 | xcsift
30+
swift build 2>&1 | xcsift --quiet
3031
""",
3132
helpNames: [.short, .long]
3233
)
@@ -37,6 +38,9 @@ struct XCSift: ParsableCommand {
3738
@Flag(name: [.short, .long], help: "Print detailed warnings list (by default only warning count is shown)")
3839
var warnings: Bool = false
3940

41+
@Flag(name: [.short, .long], help: "Suppress output when build succeeds with no warnings or errors")
42+
var quiet: Bool = false
43+
4044
func run() throws {
4145
if version {
4246
print(getVersion())
@@ -57,7 +61,7 @@ struct XCSift: ParsableCommand {
5761
}
5862

5963
let result = parser.parse(input: input, printWarnings: warnings)
60-
outputResult(result)
64+
outputResult(result, quiet: quiet)
6165
}
6266

6367
private func readStandardInput() -> String {
@@ -76,7 +80,11 @@ struct XCSift: ParsableCommand {
7680
}
7781
}
7882

79-
private func outputResult(_ result: BuildResult) {
83+
private func outputResult(_ result: BuildResult, quiet: Bool) {
84+
// In quiet mode, suppress output if build succeeded with no warnings or errors
85+
if quiet && result.status == "success" && result.summary.warnings == 0 {
86+
return
87+
}
8088
outputJSON(result)
8189
}
8290

0 commit comments

Comments
 (0)