mirror of
https://github.com/Sunnyyoung/WeChatTweak-macOS.git
synced 2026-03-03 08:37:47 +08:00
reorder code blocks
This commit is contained in:
parent
3cc0f2c5c6
commit
0682644327
|
|
@ -9,6 +9,8 @@ import Foundation
|
||||||
import MachO
|
import MachO
|
||||||
|
|
||||||
struct Config: Decodable {
|
struct Config: Decodable {
|
||||||
|
static let `default` = URL(string:"https://raw.githubusercontent.com/sunnyyoung/WeChatTweak/refs/heads/master/config.json")!
|
||||||
|
|
||||||
enum Arch: String, Decodable {
|
enum Arch: String, Decodable {
|
||||||
case arm64
|
case arm64
|
||||||
case x86_64
|
case x86_64
|
||||||
|
|
@ -81,7 +83,7 @@ struct Config: Decodable {
|
||||||
let version: String
|
let version: String
|
||||||
let targets: [Target]
|
let targets: [Target]
|
||||||
|
|
||||||
static func load(from url: URL) async throws -> [Config] {
|
static func load(url: URL = Self.default) async throws -> [Config] {
|
||||||
if url.isFileURL {
|
if url.isFileURL {
|
||||||
return try JSONDecoder().decode(
|
return try JSONDecoder().decode(
|
||||||
[Config].self,
|
[Config].self,
|
||||||
|
|
|
||||||
|
|
@ -8,15 +8,20 @@ import Foundation
|
||||||
import Dispatch
|
import Dispatch
|
||||||
import ArgumentParser
|
import ArgumentParser
|
||||||
|
|
||||||
|
// MARK: Versions
|
||||||
|
extension Tweak {
|
||||||
struct Versions: AsyncParsableCommand {
|
struct Versions: AsyncParsableCommand {
|
||||||
static let configuration = CommandConfiguration(abstract: "List all supported WeChat versions")
|
static let configuration = CommandConfiguration(abstract: "List all supported WeChat versions")
|
||||||
|
|
||||||
mutating func run() async throws {
|
mutating func run() async throws {
|
||||||
try await Config.load(from: Tweak.config).forEach({ print($0.version) })
|
try await Config.load().forEach({ print($0.version) })
|
||||||
Darwin.exit(EXIT_SUCCESS)
|
Darwin.exit(EXIT_SUCCESS)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: Patch
|
||||||
|
extension Tweak {
|
||||||
struct Patch: AsyncParsableCommand {
|
struct Patch: AsyncParsableCommand {
|
||||||
enum Error: LocalizedError {
|
enum Error: LocalizedError {
|
||||||
case invalidApp
|
case invalidApp
|
||||||
|
|
@ -66,7 +71,7 @@ struct Patch: AsyncParsableCommand {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
var config: URL = Tweak.config
|
var config: URL = Config.default
|
||||||
|
|
||||||
mutating func run() async throws {
|
mutating func run() async throws {
|
||||||
print("------ Version ------")
|
print("------ Version ------")
|
||||||
|
|
@ -76,7 +81,7 @@ struct Patch: AsyncParsableCommand {
|
||||||
print("WeChat version: \(version)")
|
print("WeChat version: \(version)")
|
||||||
|
|
||||||
print("------ Config ------")
|
print("------ Config ------")
|
||||||
guard let config = (try await Config.load(from: self.config)).first(where: { $0.version == version }) else {
|
guard let config = (try await Config.load()).first(where: { $0.version == version }) else {
|
||||||
throw Error.unsupportedVersion
|
throw Error.unsupportedVersion
|
||||||
}
|
}
|
||||||
print("Matched config: \(config)")
|
print("Matched config: \(config)")
|
||||||
|
|
@ -98,6 +103,9 @@ struct Patch: AsyncParsableCommand {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: Tweak
|
||||||
struct Tweak: AsyncParsableCommand {
|
struct Tweak: AsyncParsableCommand {
|
||||||
static let configuration = CommandConfiguration(
|
static let configuration = CommandConfiguration(
|
||||||
commandName: "wechattweak",
|
commandName: "wechattweak",
|
||||||
|
|
@ -108,8 +116,6 @@ struct Tweak: AsyncParsableCommand {
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
static let config = URL(string:"https://raw.githubusercontent.com/sunnyyoung/WeChatTweak/refs/heads/master/config.json")!
|
|
||||||
|
|
||||||
mutating func run() async throws {
|
mutating func run() async throws {
|
||||||
print(Tweak.helpMessage())
|
print(Tweak.helpMessage())
|
||||||
Darwin.exit(EXIT_SUCCESS)
|
Darwin.exit(EXIT_SUCCESS)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user