mirror of
https://github.com/Sunnyyoung/WeChatTweak-macOS.git
synced 2025-12-17 09:51:56 +08:00
subcommand: add versions
This commit is contained in:
parent
003643d063
commit
a58f04b1d4
12
README.md
12
README.md
|
|
@ -1,7 +1,6 @@
|
||||||
# WeChatTweak
|
# WeChatTweak
|
||||||
|
|
||||||
[](LICENSE)
|
A command-line tool for tweaking WeChat.
|
||||||
[](https://t.me/wechattweak)
|
|
||||||
|
|
||||||
## 功能
|
## 功能
|
||||||
|
|
||||||
|
|
@ -9,15 +8,16 @@
|
||||||
- 阻止自动更新
|
- 阻止自动更新
|
||||||
- 客户端多开
|
- 客户端多开
|
||||||
|
|
||||||
## 安装
|
## 安装&使用
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# 首次安装
|
||||||
brew install sunnyyoung/tap/wechattweak
|
brew install sunnyyoung/tap/wechattweak
|
||||||
```
|
|
||||||
|
|
||||||
## 使用
|
# 更新
|
||||||
|
brew upgrade wechattweak
|
||||||
|
|
||||||
```bash
|
# 使用
|
||||||
wechattweak patch
|
wechattweak patch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,15 @@ import Foundation
|
||||||
import Dispatch
|
import Dispatch
|
||||||
import ArgumentParser
|
import ArgumentParser
|
||||||
|
|
||||||
|
struct Versions: AsyncParsableCommand {
|
||||||
|
static let configuration = CommandConfiguration(abstract: "List all supported WeChat versions")
|
||||||
|
|
||||||
|
mutating func run() async throws {
|
||||||
|
try await Config.load(from: Tweak.config).forEach({ print($0.version) })
|
||||||
|
Darwin.exit(EXIT_SUCCESS)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct Patch: AsyncParsableCommand {
|
struct Patch: AsyncParsableCommand {
|
||||||
enum Error: LocalizedError {
|
enum Error: LocalizedError {
|
||||||
case invalidApp
|
case invalidApp
|
||||||
|
|
@ -57,42 +66,35 @@ struct Patch: AsyncParsableCommand {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
var config: URL = URL(string: "https://raw.githubusercontent.com/sunnyyoung/WeChatTweak/refs/heads/feature/2.0/config.json")!
|
var config: URL = Tweak.config
|
||||||
|
|
||||||
mutating func run() async throws {
|
mutating func run() async throws {
|
||||||
do {
|
print("------ Version ------")
|
||||||
print("------ Version ------")
|
guard let version = try await Command.version(app: self.app) else {
|
||||||
guard let version = try await Command.version(app: self.app) else {
|
throw Error.invalidVersion
|
||||||
throw Error.invalidVersion
|
|
||||||
}
|
|
||||||
print("\(version)")
|
|
||||||
|
|
||||||
print("------ Config ------")
|
|
||||||
guard let config = (try await Config.load(from: self.config)).first(where: { $0.version == version }) else {
|
|
||||||
throw Error.unsupportedVersion
|
|
||||||
}
|
|
||||||
print("\(config)")
|
|
||||||
|
|
||||||
print("------ Patch ------")
|
|
||||||
try await Command.patch(
|
|
||||||
app: self.app,
|
|
||||||
config: config
|
|
||||||
)
|
|
||||||
print("Done!")
|
|
||||||
|
|
||||||
print("------ Resign ------")
|
|
||||||
try await Command.resign(
|
|
||||||
app: self.app
|
|
||||||
)
|
|
||||||
print("Done!")
|
|
||||||
|
|
||||||
print("------🎉 Done!------")
|
|
||||||
Darwin.exit(EXIT_SUCCESS)
|
|
||||||
} catch {
|
|
||||||
print("------🚨 Error------")
|
|
||||||
print("\(error.localizedDescription)")
|
|
||||||
Darwin.exit(EXIT_FAILURE)
|
|
||||||
}
|
}
|
||||||
|
print("WeChat version: \(version)")
|
||||||
|
|
||||||
|
print("------ Config ------")
|
||||||
|
guard let config = (try await Config.load(from: self.config)).first(where: { $0.version == version }) else {
|
||||||
|
throw Error.unsupportedVersion
|
||||||
|
}
|
||||||
|
print("Matched config: \(config)")
|
||||||
|
|
||||||
|
print("------ Patch ------")
|
||||||
|
try await Command.patch(
|
||||||
|
app: self.app,
|
||||||
|
config: config
|
||||||
|
)
|
||||||
|
print("Done!")
|
||||||
|
|
||||||
|
print("------ Resign ------")
|
||||||
|
try await Command.resign(
|
||||||
|
app: self.app
|
||||||
|
)
|
||||||
|
print("Done!")
|
||||||
|
|
||||||
|
Darwin.exit(EXIT_SUCCESS)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -101,10 +103,13 @@ struct Tweak: AsyncParsableCommand {
|
||||||
commandName: "wechattweak",
|
commandName: "wechattweak",
|
||||||
abstract: "A command-line tool for tweaking WeChat.",
|
abstract: "A command-line tool for tweaking WeChat.",
|
||||||
subcommands: [
|
subcommands: [
|
||||||
|
Versions.self,
|
||||||
Patch.self
|
Patch.self
|
||||||
],
|
],
|
||||||
defaultSubcommand: Self.self
|
defaultSubcommand: Self.self
|
||||||
)
|
)
|
||||||
|
|
||||||
|
static let config = URL(string:"https://raw.githubusercontent.com/sunnyyoung/WeChatTweak/refs/heads/feature/2.0/config.json")!
|
||||||
}
|
}
|
||||||
|
|
||||||
Task {
|
Task {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user