feat: print complete default configuration from CLI
This commit is contained in:
@@ -110,6 +110,10 @@ struct ConfigurationChecks {
|
||||
let fallback = home.appendingPathComponent(".config/terebi/config.toml")
|
||||
let config = xdg.appendingPathComponent("terebi/config.toml")
|
||||
let defaults = PlayerConfiguration()
|
||||
let printed = root.appendingPathComponent("printed-defaults.toml")
|
||||
try Data(PlayerConfiguration.defaultTOML.utf8).write(to: printed)
|
||||
try require(try PlayerConfiguration.load(from: printed) == defaults,
|
||||
"printed TOML is directly usable and preserves all default behavior and bindings")
|
||||
try require(!defaults.showBufferInfo && !defaults.automaticQuality && defaults.snapToEdges,
|
||||
"built-in defaults hide buffer info, disable automatic quality, and enable snapping")
|
||||
try require(PlayerConfiguration.fileURL(environment: ["XDG_CONFIG_HOME": xdg.path], homeDirectory: home) == config,
|
||||
|
||||
@@ -55,6 +55,9 @@ struct PlayerCommandChecks {
|
||||
guard case .help = try PlayerCommand.parse(["--new-instance", "--help"]) else {
|
||||
fatalError("FAIL: help must not launch an independent player")
|
||||
}
|
||||
guard case .printDefaultConfig = try PlayerCommand.parse(["--print-default-config"]) else {
|
||||
fatalError("FAIL: printing defaults must not launch a player")
|
||||
}
|
||||
|
||||
for arguments in [["--url"], ["--url", canonical.absoluteString, movie.path], ["--"],
|
||||
[movie.path, movie.path], ["--unknown"], ["missing.mp4"], [directory.path],
|
||||
@@ -62,6 +65,7 @@ struct PlayerCommandChecks {
|
||||
["--new-instance", "--new-instance"], ["--new-instance", "--url"],
|
||||
["--new-instance", "--"], ["--new-instance", movie.path, movie.path],
|
||||
["--new-instance", "--unknown"], ["--no-config", "--no-config"],
|
||||
["--print-default-config", movie.path], ["--print-default-config", "--print-default-config"],
|
||||
["--no-config", "--new-instance", "--no-config"]] {
|
||||
do {
|
||||
_ = try PlayerCommand.parse(arguments, directory: directory)
|
||||
|
||||
Reference in New Issue
Block a user