Stubbing out some ideas for the scraper
This commit is contained in:
parent
6f4f905845
commit
dc8db90e52
|
@ -8,7 +8,8 @@ let package = Package(
|
|||
products: [
|
||||
// Products define the executables and libraries produced by a package, and make them visible to other packages.
|
||||
.library(name: "XcodeReleases", targets: ["XcodeReleases"]),
|
||||
.executable(name: "json-export", targets: ["json-export"])
|
||||
.executable(name: "json-export", targets: ["json-export"]),
|
||||
.executable(name: "xccheck", targets: ["xccheck"])
|
||||
],
|
||||
dependencies: [
|
||||
// Dependencies declare other packages that this package depends on.
|
||||
|
@ -18,6 +19,7 @@ let package = Package(
|
|||
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
|
||||
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
|
||||
.target(name: "XcodeReleases", dependencies: []),
|
||||
.target(name: "json-export", dependencies: ["XcodeReleases"])
|
||||
.target(name: "json-export", dependencies: ["XcodeReleases"]),
|
||||
.target(name: "xccheck", dependencies: ["XcodeReleases"])
|
||||
]
|
||||
)
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
//
|
||||
// File.swift
|
||||
//
|
||||
//
|
||||
// Created by David DeLong on 9/11/19.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import WebKit
|
||||
|
||||
class Scraper: NSObject, WKNavigationDelegate, WKUIDelegate {
|
||||
|
||||
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
//
|
||||
// Step.swift
|
||||
//
|
||||
//
|
||||
// Created by David DeLong on 9/11/19.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import WebKit
|
||||
|
||||
class Step: NSObject, WKNavigationDelegate {
|
||||
|
||||
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
|
||||
// load up the new dom
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
//
|
||||
// main.swift
|
||||
//
|
||||
//
|
||||
// Created by Xcode Releases on 9/11/19.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import WebKit
|
||||
import AppKit
|
||||
|
||||
class XCCheckDelegate: NSObject, NSApplicationDelegate {
|
||||
|
||||
var lastPrintedString: String?
|
||||
func applicationDidFinishLaunching(_ notification: Notification) {
|
||||
print("Hello world!")
|
||||
printPercentage(0)
|
||||
}
|
||||
|
||||
func printPercentage(_ v: Int) {
|
||||
guard v <= 100 else { return }
|
||||
if let last = lastPrintedString {
|
||||
print("\u{001B}[2K")
|
||||
lastPrintedString = nil
|
||||
}
|
||||
let val = min(max(v, 0), 100)
|
||||
let string = pieces(for: val)
|
||||
print(string)
|
||||
lastPrintedString = string
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.125, execute: { self.printPercentage(v + 1) })
|
||||
}
|
||||
|
||||
private func pieces(for percentage: Int) -> String {
|
||||
let value = CGFloat(percentage) / 8.0
|
||||
let wholeBoxes = Int(floor(value))
|
||||
var final = ""
|
||||
for _ in 0 ..< wholeBoxes {
|
||||
final.append("█")
|
||||
}
|
||||
let remaining = value - floor(value)
|
||||
switch remaining {
|
||||
case 0 ..< 0.125: final.append(" ")
|
||||
case 0.125 ..< 0.25: final.append("▏")
|
||||
case 0.25 ..< 0.375: final.append("▎")
|
||||
case 0.375 ..< 0.5: final.append("▍")
|
||||
case 0.5 ..< 0.625: final.append("▌")
|
||||
case 0.625 ..< 0.75: final.append("▋")
|
||||
case 0.75 ..< 0.875: final.append("▊")
|
||||
case 0.875 ..< 1: final.append("▉")
|
||||
default: fatalError()
|
||||
}
|
||||
let remainingCharacterCount = 12 - final.count
|
||||
if remainingCharacterCount > 0 {
|
||||
let spaces = String(repeating: " ", count: remainingCharacterCount)
|
||||
final.append(spaces)
|
||||
}
|
||||
final = "[" + final + "] "
|
||||
|
||||
if percentage < 10 {
|
||||
final += " \(percentage)%"
|
||||
} else if percentage < 100 {
|
||||
final += " \(percentage)%"
|
||||
} else {
|
||||
final += "\(percentage)%"
|
||||
}
|
||||
|
||||
return final
|
||||
}
|
||||
}
|
||||
|
||||
print(CommandLine.arguments)
|
||||
|
||||
var delegate: XCCheckDelegate? = XCCheckDelegate()
|
||||
NSApplication.shared.delegate = delegate
|
||||
NSApplication.shared.run()
|
||||
delegate = nil
|
Loading…
Reference in New Issue