Skip to content

Commit

Permalink
Hidden verbose flag
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed Mar 18, 2018
1 parent b46315d commit c83c922
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
4 changes: 2 additions & 2 deletions generate_appcast/Appcast.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ func makeError(code: SUError, _ description: String) -> NSError {
]);
}

func makeAppcast(archivesSourceDir: URL, privateKey: SecKey) throws -> [String:[ArchiveItem]] {
func makeAppcast(archivesSourceDir: URL, privateKey: SecKey, verbose: Bool) throws -> [String:[ArchiveItem]] {
let comparator = SUStandardVersionComparator();

let allUpdates = (try unarchiveUpdates(archivesSourceDir: archivesSourceDir))
let allUpdates = (try unarchiveUpdates(archivesSourceDir: archivesSourceDir, verbose:verbose))
.sorted(by: {
.orderedDescending == comparator.compareVersion($0.version, toVersion:$1.version)
})
Expand Down
15 changes: 13 additions & 2 deletions generate_appcast/Unarchive.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ func unarchive(itemPath:URL, archiveDestDir: URL, callback: @escaping (Error?) -
}
}

func unarchiveUpdates(archivesSourceDir: URL) throws -> [ArchiveItem] {
func unarchiveUpdates(archivesSourceDir: URL, verbose: Bool) throws -> [ArchiveItem] {
let archivesDestDir = archivesSourceDir.appendingPathComponent(".tmp");
if verbose {
print("Unarchiving to temp directory", archivesDestDir.path);
}

let group = DispatchGroup();

Expand All @@ -60,10 +63,18 @@ func unarchiveUpdates(archivesSourceDir: URL) throws -> [ArchiveItem] {
}

let addItem = {
if let item = try? ArchiveItem(fromArchive: itemPath, unarchivedDir: archiveDestDir) {
do {
let item = try ArchiveItem(fromArchive: itemPath, unarchivedDir: archiveDestDir);
if verbose {
print("Found archive", item);
}
objc_sync_enter(unarchived);
unarchived.append(item);
objc_sync_exit(unarchived);
} catch {
if verbose {
print("Skipped", item, error);
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion generate_appcast/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import Foundation

var verbose = false;

func main() {
let args = CommandLine.arguments;
if args.count < 3 {
Expand All @@ -26,7 +28,7 @@ func main() {
do {
let privateKey = try loadPrivateKey(privateKeyPath: privateKeyPath);
do {
let allUpdates = try makeAppcast(archivesSourceDir: archivesSourceDir, privateKey: privateKey);
let allUpdates = try makeAppcast(archivesSourceDir: archivesSourceDir, privateKey: privateKey, verbose:verbose);

for (appcastFile, updates) in allUpdates {
let appcastDestPath = URL(fileURLWithPath: appcastFile, relativeTo: archivesSourceDir);
Expand Down

0 comments on commit c83c922

Please sign in to comment.