diff --git a/generate_appcast/main.swift b/generate_appcast/main.swift index ff0df099..57ae99f2 100644 --- a/generate_appcast/main.swift +++ b/generate_appcast/main.swift @@ -13,8 +13,13 @@ var verbose = false; func printUsage() { let command = URL(fileURLWithPath: CommandLine.arguments.first!).lastPathComponent; print("Generate appcast from a directory of Sparkle updates\n", - "Usage: \(command) < -f private key path | -k keychain_path -n key_name > \n", - " e.g. \(command) -f dsa_priv.pem archives/\n", + "Usage:\n", + " \(command) < -f private key path | -k keychain_path -n key_name > \n", + " e.g. \(command) -k ~/Library/Keychains/login.keychain -n 'My Private Key' archives/\n", + "\nOR (legacy)\n\n", + " \(command) \n", + " e.g. \(command) dsa_priv.pem archives/\n", + "\n", " Appcast files and deltas will be written to the archives directory.\n", " Note that pkg-based updates are not supported.\n" ) @@ -22,17 +27,16 @@ func printUsage() { func main() { let args = CommandLine.arguments; - if args.count < 4 { + if args.count < 3 { printUsage() exit(1) } - let firstOption = args[1] let privateKey: SecKey - if firstOption == "-f" && args.count == 4 { + if args.count == 3 || (args.count == 4 && args[1] == "-f") { // private key specified by filename - let privateKeyURL = URL(fileURLWithPath: args[2]) + let privateKeyURL = URL(fileURLWithPath: args.count == 3 ? args[1] : args[2]) do { privateKey = try loadPrivateKey(at: privateKeyURL) @@ -41,12 +45,12 @@ func main() { exit(1) } } - else if (firstOption == "-n" || firstOption == "-k") && args.count == 6 { + else if args.count == 6 && (args[1] == "-n" || args[1] == "-k") { // private key specified by keychain + key name let keyName: String let keychainURL: URL - if firstOption == "-n" { + if args[1] == "-n" { if args[3] != "-k" { printUsage() exit(1)