feat: load optional XDG TOML configuration with session overrides
This commit is contained in:
@@ -16,11 +16,12 @@ struct PlayerCommandChecks {
|
||||
let instanceFile = directory.appendingPathComponent("--new-instance")
|
||||
for file in [movie, optionFile, colonFile, instanceFile] { try Data().write(to: file) }
|
||||
|
||||
func opened(_ arguments: [String], newInstance: Bool = false) throws -> URL? {
|
||||
guard case .launch(let url, let independent) = try PlayerCommand.parse(arguments, directory: directory) else {
|
||||
func opened(_ arguments: [String], newInstance: Bool = false, noConfig: Bool = false) throws -> URL? {
|
||||
guard case .launch(let url, let independent, let bypass) = try PlayerCommand.parse(arguments, directory: directory) else {
|
||||
fatalError("FAIL: expected a launch command")
|
||||
}
|
||||
require(independent == newInstance, "launch mode preserves default reuse or explicit independence")
|
||||
require(bypass == noConfig, "configuration loading defaults on and can be explicitly bypassed")
|
||||
return url
|
||||
}
|
||||
require(try opened([movie.lastPathComponent]) == movie, "relative paths resolve against invocation directory, preserving spaces")
|
||||
@@ -40,6 +41,17 @@ struct PlayerCommandChecks {
|
||||
"independent launch preserves the filename terminator")
|
||||
require(try opened(["--", "--new-instance"]) == instanceFile,
|
||||
"an escaped instance flag is a filename, not a launch option")
|
||||
require(try opened(["--no-config"], noConfig: true) == nil, "configuration bypass can omit media")
|
||||
require(try opened(["--no-config", movie.path], noConfig: true) == movie,
|
||||
"configuration bypass retains local media delivery")
|
||||
require(try opened(["--new-instance", "--no-config", "--url", canonical.absoluteString],
|
||||
newInstance: true, noConfig: true) == canonical,
|
||||
"independent bypass retains explicit YouTube identity")
|
||||
require(try opened(["--no-config", "--new-instance", "--", "--help"],
|
||||
newInstance: true, noConfig: true) == optionFile, "launch options work in either order")
|
||||
guard case .help = try PlayerCommand.parse(["--no-config", "--new-instance", "--help"]) else {
|
||||
fatalError("FAIL: help with launch options must not launch a player")
|
||||
}
|
||||
guard case .help = try PlayerCommand.parse(["--new-instance", "--help"]) else {
|
||||
fatalError("FAIL: help must not launch an independent player")
|
||||
}
|
||||
@@ -49,7 +61,8 @@ struct PlayerCommandChecks {
|
||||
["file://remote-host/video.mp4"], ["https://example.com/video.mp4"],
|
||||
["--new-instance", "--new-instance"], ["--new-instance", "--url"],
|
||||
["--new-instance", "--"], ["--new-instance", movie.path, movie.path],
|
||||
["--new-instance", "--unknown"]] {
|
||||
["--new-instance", "--unknown"], ["--no-config", "--no-config"],
|
||||
["--no-config", "--new-instance", "--no-config"]] {
|
||||
do {
|
||||
_ = try PlayerCommand.parse(arguments, directory: directory)
|
||||
fatalError("FAIL: accepted an invalid command")
|
||||
|
||||
Reference in New Issue
Block a user