Skip to content

Commit

Permalink
Merge pull request #69 from voidless/xcode_warnings
Browse files Browse the repository at this point in the history
Add option to print results as xcode warnings for build phases
  • Loading branch information
onevcat authored Jan 9, 2024
2 parents 89833bd + 1b0156f commit 619938a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Sources/FengNiao/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ let EX_OK: Int32 = 0
let EX_USAGE: Int32 = 64
#endif

let EXIT_UNUSED_RESOURCES: Int32 = 1

let cli = CommandLineKit.CommandLine()
cli.formatOutput = { s, type in
var str: String
Expand Down Expand Up @@ -79,6 +81,9 @@ let skipProjRefereceCleanOption = BoolOption(
)
cli.addOption(skipProjRefereceCleanOption)

let xcodeWarningsOption = BoolOption(longFlag: "xcode-warnings", helpMessage: "Print results as xcode warnings and return non zero code if any.")
cli.addOption(xcodeWarningsOption)

let versionOption = BoolOption(longFlag: "version", helpMessage: "Print version.")
cli.addOption(versionOption)

Expand Down Expand Up @@ -144,6 +149,14 @@ if unusedFiles.isEmpty {
exit(EX_OK)
}

if xcodeWarningsOption.value {
for file in unusedFiles.sorted(by: { $0.size > $1.size }) {
print("\(file.path.string): warning: Unused resource of size \(file.readableSize)")
}

exit(EXIT_UNUSED_RESOURCES);
}

if !isForce {
var result = promptResult(files: unusedFiles)
while result == .list {
Expand Down

0 comments on commit 619938a

Please sign in to comment.