]> njoseph.me Git - nimcoon.git/commitdiff
Delete unnecessary return statements
authorJoseph Nuthalapati <njoseph@riseup.net>
Fri, 5 Jun 2020 16:48:45 +0000 (22:18 +0530)
committerJoseph Nuthalapati <njoseph@riseup.net>
Fri, 5 Jun 2020 16:48:45 +0000 (22:18 +0530)
src/lib.nim
src/nimcoon.nim

index 26df76293947f83968d4e318d2b8883246357d80..62d05531b8f1194f8c6fa8f4e3b59af3ef3ca4d9 100644 (file)
@@ -44,7 +44,7 @@ proc getYoutubePage*(searchQuery: string): string =
   let queryParam = encodeUrl(searchQuery)
   let client = newHttpClient()
   let response = get(client, &"https://www.youtube.com/results?hl=en&search_query={queryParam}")
-  return $response.body
+  $response.body
 
 proc getPeerTubeMagnetLink(url: string): string =
   # Gets the magnet link of the best possible resolutino from PeerTube
@@ -81,7 +81,7 @@ func buildPlayerArgs(url: string, options: Table[string, bool], player: string):
     else: url
   let musicOnly = if options["musicOnly"]: "--no-video" else: ""
   let fullScreen = if options["fullScreen"]: "--fullscreen" else: ""
-  return filterIt([url, musicOnly, fullScreen], it != "")
+  filterIt([url, musicOnly, fullScreen], it != "")
 
 proc play*(player: string, options: Table[string, bool], url: string, title: string = "") =
   let args = buildPlayerArgs(url, options, player)
@@ -95,25 +95,22 @@ proc play*(player: string, options: Table[string, bool], url: string, title: str
 func buildMusicDownloadArgs*(url: string): seq[string] =
   {.noSideEffect.}:
     let downloadLocation = &"'{expandTilde(musicDownloadDirectory)}/%(title)s.%(ext)s'"
-    return @["--ignore-errors", "-f", "bestaudio", "--extract-audio", "--audio-format", "mp3", "--audio-quality", "0", "-o", downloadLocation, url]
+    @["--ignore-errors", "-f", "bestaudio", "--extract-audio", "--audio-format", "mp3", "--audio-quality", "0", "-o", downloadLocation, url]
 
 func buildVideoDownloadArgs*(url: string): seq[string] =
   {.noSideEffect.}:
     let downloadLocation = &"'{expandTilde(videoDownloadDirectory)}/%(title)s.%(ext)s'"
-    return @["-f", "best", "-o", downloadLocation, url]
+    @["-f", "best", "-o", downloadLocation, url]
 
 proc download*(args: openArray[string], title: string) =
   styledEcho "\n", fgGreen, "Downloading ", styleBright, fgMagenta, title
   discard execShellCmd(&"youtube-dl {args.join(\" \")}")
 
-func urlLongen(url: string): string =
-  url.replace("youtu.be/", "www.youtube.com/watch?v=")
+func urlLongen(url: string): string = url.replace("youtu.be/", "www.youtube.com/watch?v=")
 
-func stripZshEscaping(url: string): string =
-  url.replace("\\", "")
+func stripZshEscaping(url: string): string = url.replace("\\", "")
 
-func sanitizeURL*(url: string): string =
-  urlLongen(stripZshEscaping(url))
+func sanitizeURL*(url: string): string = urlLongen(stripZshEscaping(url))
 
 proc directPlay*(url: string, player: string, options: Table[string, bool]) =
   let url =
@@ -153,9 +150,10 @@ proc handleUserInput(searchResult: SearchResult, options: Table[string, bool], p
     play(player, options, searchResult.url, searchResult.title)
 
 proc present*(searchResults: SearchResults, options: Table[string, bool], selectionRange: SelectionRange, player: string) =
-  #[ Continuously present options till the user quits the application
-       selectionRange: Currently available range to choose from depending on pagination
-  ]#
+  ##[ Continuously present options till the user quits the application
+
+        selectionRange: Currently available range to choose from depending on pagination
+  ]##
 
   let userInput = offerSelection(searchResults, options, selectionRange)
 
index 1bb0b7438bbbd254b7be8ab30752a923e9fd0fdb..20b9280c54d990af5889176440d7ca1417842949 100644 (file)
@@ -25,7 +25,7 @@ proc parseArguments(): CommandLineOptions =
       of "d", "download": options["download"] = true
     of cmdEnd: discard
 
-  return (searchQuery, options)
+  (searchQuery, options)
 
 
 proc isValidOptions*(options: Options): bool =
@@ -35,7 +35,7 @@ proc isValidOptions*(options: Options): bool =
     if options[combination[0]] and options[combination[1]]:
      stderr.writeLine fmt"Incompatible options provided: {combination[0]} and {combination[1]}"
      return false
-  return true
+  true
 
 proc main() =
   let