pco_chords/src/pco_chords.nim
Jonathan Bernard 4833cc4f37 Better column support, redefine keys.
- Fix transposition bug (wrap around past G->A)
- Better chord parsing and handling (bass transposed correctly)
- Add column and page break support.
2022-10-29 10:56:56 -05:00

45 lines
1.1 KiB
Nim

import std/logging, std/strutils
import docopt
import pco_chordspkg/ast, pco_chordspkg/cliconstants, pco_chordspkg/html
when isMainModule:
try:
let consoleLogger = newConsoleLogger(
levelThreshold=lvlInfo,
fmtStr="pco_chords - $levelname: ",
useStderr=true)
logging.addHandler(consoleLogger)
# Parse arguments
let args = docopt(USAGE, version = PCO_CHORDSVERSION)
if args["--debug"]:
consoleLogger.levelThreshold = lvlDebug
if args["--echo-args"]: stderr.writeLine($args)
if args["help"]:
stderr.writeLine(USAGE & "\n")
stderr.writeLine(ONLINE_HELP)
quit()
let inputText =
if args["--input"]: readFile($args["--input"])
else: readAll(stdin)
let ast = parseChordChart(inputText)
debug "Parsed AST\p" &
"-".repeat(16) & "\p" &
$ast & "\p" &
"-".repeat(16) & "\p"
let outputHtml = ast.toHtml()
if args["--output"]: writeFile($args["--output"], outputHtml)
else: stdout.write(outputHtml)
except:
fatal getCurrentExceptionMsg()
debug getCurrentException().getStackTrace()
quit(QuitFailure)