CheckLocalizations: use NSUserDefaults to read args

This commit is contained in:
Kevin Wojniak committed 2015-07-10 13:10:38 -07:00
1 parent 0d9597c9a9
commit 14fe42e7da
2 files changed
+8 -8

No files matched your search

+1 -1
View File
@@ -29,5 +29,5 @@ ci:
check-localizations:
xcrun swiftc -sdk `xcrun --show-sdk-path` -o "$(TMPDIR)/CheckLocalizations" Sparkle/CheckLocalizations.swift
"$(TMPDIR)/CheckLocalizations" . "$(TMPDIR)/LocalizationsReport.htm"
"$(TMPDIR)/CheckLocalizations" -root . -htmlPath "$(TMPDIR)/LocalizationsReport.htm"
open "$(TMPDIR)/LocalizationsReport.htm"
+7 -7
View File
@@ -12,21 +12,21 @@ func escapeHTML(str: String) -> String {
die("NSXMLNode failure"); return ""
}
let args = NSProcessInfo.processInfo().arguments
if args.count < 3 {
let ud = NSUserDefaults.standardUserDefaults()
let sparkleRoot = ud.objectForKey("root") as? String
let htmlPath = ud.objectForKey("htmlPath") as? String
if sparkleRoot == nil || htmlPath == nil {
die("Missing arguments")
}
let sparkleRoot = args[1] as! String
let htmlPath = args[2] as! String
let enStringsPath = sparkleRoot + "/Sparkle/en.lproj/Sparkle.strings"
let enStringsPath = sparkleRoot! + "/Sparkle/en.lproj/Sparkle.strings"
let enStringsDict = NSDictionary(contentsOfFile: enStringsPath)
if enStringsDict == nil {
die("Invalid English strings")
}
let enStringsDictKeys = enStringsDict!.allKeys
let dirPath = sparkleRoot + "/Sparkle"
let dirPath = sparkleRoot! + "/Sparkle"
let dirContents = NSFileManager.defaultManager().contentsOfDirectoryAtPath(dirPath, error: nil) as! [String]
let css =
"body { font-family: sans-serif; font-size: 10pt; }" +
@@ -93,6 +93,6 @@ for dirEntry in dirContents {
html += "</body></html>"
var err: NSError?
if !html.writeToFile(htmlPath, atomically: true, encoding: NSUTF8StringEncoding, error: &err) {
if !html.writeToFile(htmlPath!, atomically: true, encoding: NSUTF8StringEncoding, error: &err) {
die("Can't write report: \(err)")
}