upgrade hwylterm
This commit is contained in:
parent
a519788c9f
commit
872bb0a7b6
3 changed files with 25 additions and 38 deletions
|
@ -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": {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue