This commit is contained in:
Kyle Brown 2020-12-17 19:03:09 -08:00
parent 844afb08f6
commit 41407b3f35
2 changed files with 31 additions and 11 deletions

View file

@ -13,3 +13,5 @@ bin = @["renamer"]
requires "nim >= 1.4.2"
requires "zero_functional >= 1.2.1"
requires "docopt >= 0.6.7"

View file

@ -1,3 +1,19 @@
let doc = """
Renamer.
Usage:
renamer [<from>] [<to>] [--season=<se>]
renamer (-h | --help)
renamer [--version]
Options:
-h, --help Show this screen.
-v, --version Show version.
--season=<se> Season of show. [Default is 01]
"""
import docopt
import lists
import os
import re
@ -85,20 +101,22 @@ proc main() =
# Initializes season to be blank. Can be overridden with command
var
file_list = initDoublyLinkedList[string]()
season = ""
season = "01"
fromDir = ""
toDir = ""
# Parses for a season on command line
let params = commandLineParams()
for i in 0 ..< params.len():
if params[i] == "-s" or params[i] == "--season":
# Sets format as S00E00 format
season = params[i+1]
elif params[i] == "-f" or params[i] == "--from":
fromDir = params[i+1] & "/"
elif params[i] == "-t" or params[i] == "--to":
toDir = params[i+1] & "/"
let args = docopt(doc, version = "Renamer 0.1")
if args["<from>"]:
fromDir = $args["<from>"] & "/"
if args["<to>"]:
toDir = $args["<to>"] & "/"
if args["--season"]:
let tmpseason = $args["--season"]
# Ensure seasons below 10 start with 0. Example is 03
if tmpseason.len() < 2:
season = "0" & tmpseason
else: season = tmpseason
if not isatty(stdin):
while true: