Files
Timofey Solomko 4ec437e912 [swcomp] Add benchmark convert command
This command converts save file from old format to the new one.
2026-02-12 21:44:35 +08:00

26 lines
714 B
Swift

// Copyright (c) 2026 Timofey Solomko
// Licensed under MIT License
//
// See LICENSE for license information
import Foundation
import SwiftCLI
final class ConvertCommand: Command {
let name = "convert"
let shortDescription = "Converts save file to a new format"
let longDescription = "Converts specified with saved benchmark results to a new format"
@Param var path: String
func execute() throws {
let oldSaveFile = try OldSaveFile.load(from: self.path)
let encoder = JSONEncoder()
encoder.outputFormatting = [.prettyPrinted, .sortedKeys]
let data = try encoder.encode(SaveFile(oldSaveFile))
try data.write(to: URL(fileURLWithPath: path))
}
}