Skip to content

Commit

Permalink
Add option to print results as xcode warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
voidless committed Sep 6, 2022
1 parent 17bbd6f commit 1b0156f
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 1b0156f

Please sign in to comment.