Restored legacy CLI for backward compatibility

This commit is contained in:
Tamás Lustyik committed 2018-05-13 21:33:03 +02:00
1 parent 3f3ace055d
commit a582d46096
1 file changed
+12 -8
+12 -8
View File
@@ -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 > <directory with update archives>\n",
" e.g. \(command) -f dsa_priv.pem archives/\n",
"Usage:\n",
" \(command) < -f private key path | -k keychain_path -n key_name > <directory with update archives>\n",
" e.g. \(command) -k ~/Library/Keychains/login.keychain -n 'My Private Key' archives/\n",
"\nOR (legacy)\n\n",
" \(command) <private key path> <directory with update archives>\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)