iBook/ipad_app/Sources/CLIMain.swift

23 lines
697 B
Swift

import Foundation
@available(macOS 10.15, iOS 13.0, *)
@main
struct CLIMain {
static func main() async {
guard CommandLine.arguments.count > 1 else {
print("用法: IpadReaderCLI <bundle.zip>")
return
}
let zipPath = CommandLine.arguments[1]
let url = URL(fileURLWithPath: zipPath)
let importer = BundleImporter()
do {
let idx = try await importer.importZipFile(at: url)
print("导入成功,书籍数: \(idx.books.count)")
print("统计: 年总时长 \(idx.stats.global.year_total_minutes/60) 小时")
} catch {
print("导入失败: \(error)")
}
}
}