X-Git-Url: https://njoseph.me/gitweb/nimcoon.git/blobdiff_plain/26229fac9c93a427a85e86b899ed54639116de9a..5f9cdfeff96bb2848e3dc72bab410859d78b9c65:/src/nimcoon.nim diff --git a/src/nimcoon.nim b/src/nimcoon.nim index e1cbb23..9df18a8 100644 --- a/src/nimcoon.nim +++ b/src/nimcoon.nim @@ -1,6 +1,5 @@ import parseopt, - strformat, strutils, tables @@ -12,10 +11,19 @@ import proc parseArguments(): CommandLineOptions = + var searchQuery = "" - options = to_table({"musicOnly": false, "feelingLucky": false, "fullScreen": false, "download": false, "non-interactive": false}) - + options = to_table({ + "musicOnly": false, + "feelingLucky": false, + "fullScreen": false, + "download": false, + "nonInteractive": false, + "autoPlay": false + }) + + # Non-interactive/Global options for kind, key, value in getopt(): case kind of cmdArgument: @@ -26,7 +34,8 @@ proc parseArguments(): CommandLineOptions = of "l", "lucky": options["feelingLucky"] = true of "f", "full-screen": options["fullScreen"] = true of "d", "download": options["download"] = true - of "n", "non-interactive": options["non-interactive"] = true + of "n", "non-interactive": options["nonInteractive"] = true + of "a", "auto-play": options["autoPlay"] = true of cmdEnd: discard if searchQuery == "": @@ -36,15 +45,6 @@ proc parseArguments(): CommandLineOptions = (searchQuery, options) -proc isValidOptions(options: Options): bool = - # Check for invalid combinations of options - var invalidCombinations = [("musicOnly", "fullScreen"), ("download", "fullScreen")] - result = true - for combination in invalidCombinations: - if options[combination[0]] and options[combination[1]]: - stderr.writeLine fmt"Incompatible options provided: {combination[0]} and {combination[1]}" - result = false - proc main() = let player = selectMediaPlayer() @@ -61,7 +61,7 @@ proc main() = quit(0) let searchResults = getSearchResults(searchQuery) - if options["non-interactive"]: + if options["nonInteractive"]: for index, (title, url) in searchResults: echo title echo url