import std/[strutils, terminal, unicode] import cliutils, docopt # This is just an example to get you started. A typical binary package # uses this file as the main entry point of the application. const VERSION = "0.1.0" const USAGE = """Usage: hr [] [options] Options: -c, --color Color to make the rule. -d, --double-rule Draw as ═══════════ -C, --char Character to use to make the rule """ when isMainModule: try: let args = docopt(USAGE, version = VERSION) let color = if args["--color"]: parseEnum[TerminalColors]("c" & $args["--color"]) else: cDefault let ruleChar = if args["--char"]: $args["--char"] elif args["--double-rule"]: "═" else: "─" stdout.writeLine(termFmt( repeat(ruleChar, terminalWidth()), fg = color, bg = cDefault)) if args[""]: let heading = $args[""] let padding = max(0, (terminalWidth() - runeLen(heading)) div 2) stdout.writeLine(termFmt( repeat(" ", padding) & heading & repeat(" ", padding), fg = color, bg = cDefault)) except: stderr.writeLine("hf - FATAL: " & getCurrentExceptionMsg()) stderr.writeLine(getCurrentException().getStackTrace()) quit(QuitFailure)