feat: print complete default configuration from CLI
This commit is contained in:
@@ -15,6 +15,26 @@ public struct PlayerConfiguration: Equatable, Sendable {
|
||||
self.keys = keys
|
||||
}
|
||||
|
||||
public static var defaultTOML: String {
|
||||
let defaults = Self()
|
||||
let encoder = JSONEncoder()
|
||||
encoder.outputFormatting = .withoutEscapingSlashes
|
||||
var lines = [
|
||||
"automatic_quality = \(defaults.automaticQuality)",
|
||||
"", "[ui]",
|
||||
"buffer_info = \(defaults.showBufferInfo)",
|
||||
"compact_snap_to_edges = \(defaults.snapToEdges)",
|
||||
"", "[keys]"
|
||||
]
|
||||
for (name, action) in PlayerAction.namedActions {
|
||||
let chords = defaults.keys.shortcuts(for: action).map(\.description)
|
||||
// JSON string arrays are valid TOML arrays; preserve escaping for printable keys.
|
||||
let value = String(decoding: try! encoder.encode(chords), as: UTF8.self)
|
||||
lines.append("\(name) = \(value)")
|
||||
}
|
||||
return lines.joined(separator: "\n") + "\n"
|
||||
}
|
||||
|
||||
public static func fileURL(environment: [String: String], homeDirectory: URL) -> URL {
|
||||
let directory: URL
|
||||
if let path = environment["XDG_CONFIG_HOME"], path.hasPrefix("/") {
|
||||
|
||||
Reference in New Issue
Block a user