diff --git a/nimble.lock b/nimble.lock index 9a28c05..6c07fc3 100644 --- a/nimble.lock +++ b/nimble.lock @@ -3,12 +3,12 @@ "packages": { "hwylterm": { "version": "0.1.0", - "vcsRevision": "7385a93110f95e1d67d803780efa014fdc960779", + "vcsRevision": "713c98c13f2ddea1de4004b988948ea016db163b", "url": "https://github.com/daylinmorgan/hwylterm", "downloadMethod": "git", "dependencies": [], "checksums": { - "sha1": "bf170216cff989ea17abfb97946b9f0804c0e50b" + "sha1": "f928dbf7538b3fe8aeeb70fd47ea2641cfddeaf5" } }, "yaml": { diff --git a/src/typstgen.nim b/src/typstgen.nim index 3e8b818..f1cb660 100644 --- a/src/typstgen.nim +++ b/src/typstgen.nim @@ -87,41 +87,28 @@ proc typstGen(c: Config): string = result &= c.applyTemplate(component) when isMainModule: - import hwylterm/[cli, parseopt3] - proc writeHelp() = - echo newHwylCli( - "[bold]typstgen[/] [[[faint]-h[/]]", - """ - typstgen --config typstgen.yml""", - [ - ("h", "help", "show this help"), - ("c","config", "path to config file"), - ("","check", "load config and exit"), - ] - ) - var - p = initOptParser(longNoVal= @["check"]) - configPath = "typstgen.yml" - check: bool - for kind, key, val in p.getopt(): - case kind - of cmdError: quit($bb"[red]cli error[/]: " & p.message) - of cmdEnd: assert false - of cmdArgument: quit($bb"[red] unexpected argument[/]: " & key) - of cmdShortOption, cmdLongOption: - case key - of "help", "h": - writeHelp(); quit 0 - of "config", "c": - configPath = val - of "check": - check = true + import hwylterm/hwylcli + hwylCli: + name "typstgen" + flags: + config: + T seq[string] + ? "path to config file" + - c + * @["typstgen.yml"] + check: + T bool + ? "load config and exit" + run: + for f in config: + if not fileExists(f): + quit($bbfmt("[red]error[/] file: [b]{f}[/] does not exist")) - if not fileExists(configPath): - quit($bbfmt("file: [b]{configPath}[/] does not exist")) - - let config = loadConfig(configPath) - if check: quit 0 - echo typstGen(config) + if config.len > 1: + echo "currently only one config file is considered" + let tgConfig = loadConfig(config[0]) + if check: + quit 0 + echo typstGen(tgConfig) diff --git a/typstgen.nimble b/typstgen.nimble index a9ef3b7..c9e439e 100644 --- a/typstgen.nimble +++ b/typstgen.nimble @@ -12,4 +12,4 @@ bin = @["typstgen"] requires "nim >= 2.2.0" requires "yaml >= 2.1.1" -requires "https://github.com/daylinmorgan/hwylterm#HEAD" +requires "https://github.com/daylinmorgan/hwylterm#713c98c"