feat: print complete default configuration from CLI
This commit is contained in:
@@ -2,6 +2,7 @@ import Foundation
|
||||
|
||||
enum PlayerCommand {
|
||||
case help
|
||||
case printDefaultConfig
|
||||
case launch(URL?, newInstance: Bool, noConfig: Bool)
|
||||
|
||||
static let usage = """
|
||||
@@ -9,6 +10,7 @@ enum PlayerCommand {
|
||||
terebi [--new-instance] [--no-config] --url YOUTUBE_URL
|
||||
terebi [--new-instance] [--no-config] -- FILE
|
||||
terebi --help
|
||||
terebi --print-default-config
|
||||
|
||||
Open one local media file or YouTube video and start playback, resuming saved
|
||||
video progress when available. With no arguments, open or activate the player.
|
||||
@@ -19,6 +21,7 @@ enum PlayerCommand {
|
||||
--url URL Open a YouTube video URL.
|
||||
-- Treat the following argument as a filename, even with a leading '-'.
|
||||
-h, --help Show this help without launching the player.
|
||||
--print-default-config Print the complete built-in TOML without launching.
|
||||
|
||||
Reuses the running player unless --new-instance is supplied before the media
|
||||
arguments. The command exits once macOS accepts the launch; playback and
|
||||
@@ -41,6 +44,7 @@ enum PlayerCommand {
|
||||
}
|
||||
if inputs.isEmpty { return .launch(nil, newInstance: newInstance, noConfig: noConfig) }
|
||||
if inputs == ["--help"] || inputs == ["-h"] { return .help }
|
||||
if inputs == ["--print-default-config"] { return .printDefaultConfig }
|
||||
if inputs.first == "--url" {
|
||||
guard inputs.count == 2 else { throw ArgumentError("--url requires exactly one YouTube URL.") }
|
||||
return .launch(try YouTubeResolver.validateURL(inputs[1]), newInstance: newInstance, noConfig: noConfig)
|
||||
|
||||
@@ -15,6 +15,8 @@ enum TerebiCLI {
|
||||
switch command {
|
||||
case .help:
|
||||
print(PlayerCommand.usage)
|
||||
case .printDefaultConfig:
|
||||
print(PlayerConfiguration.defaultTOML, terminator: "")
|
||||
case .launch(let url, let newInstance, let noConfig):
|
||||
let configURL = PlayerConfiguration.fileURL(environment: ProcessInfo.processInfo.environment,
|
||||
homeDirectory: FileManager.default.homeDirectoryForCurrentUser)
|
||||
|
||||
Reference in New Issue
Block a user