subcommand: add versions

This commit is contained in:
Sunny Young 2025-12-06 16:26:41 +08:00
parent 003643d063
commit a58f04b1d4
2 changed files with 44 additions and 39 deletions

View File

@ -1,7 +1,6 @@
# WeChatTweak
[![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](LICENSE)
[![README](https://img.shields.io/badge/Telegram-WeChatTweak-brightgreen.svg)](https://t.me/wechattweak)
A command-line tool for tweaking WeChat.
## 功能
@ -9,15 +8,16 @@
- 阻止自动更新
- 客户端多开
## 安装
## 安装&使用
```bash
# 首次安装
brew install sunnyyoung/tap/wechattweak
```
## 使用
# 更新
brew upgrade wechattweak
```bash
# 使用
wechattweak patch
```

View File

@ -8,6 +8,15 @@ import Foundation
import Dispatch
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 {
enum Error: LocalizedError {
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 {
do {
print("------ Version ------")
guard let version = try await Command.version(app: self.app) else {
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("------ Version ------")
guard let version = try await Command.version(app: self.app) else {
throw Error.invalidVersion
}
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",
abstract: "A command-line tool for tweaking WeChat.",
subcommands: [
Versions.self,
Patch.self
],
defaultSubcommand: Self.self
)
static let config = URL(string:"https://raw.githubusercontent.com/sunnyyoung/WeChatTweak/refs/heads/feature/2.0/config.json")!
}
Task {