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": {
|
"packages": {
|
||||||
"hwylterm": {
|
"hwylterm": {
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"vcsRevision": "7385a93110f95e1d67d803780efa014fdc960779",
|
"vcsRevision": "713c98c13f2ddea1de4004b988948ea016db163b",
|
||||||
"url": "https://github.com/daylinmorgan/hwylterm",
|
"url": "https://github.com/daylinmorgan/hwylterm",
|
||||||
"downloadMethod": "git",
|
"downloadMethod": "git",
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"checksums": {
|
"checksums": {
|
||||||
"sha1": "bf170216cff989ea17abfb97946b9f0804c0e50b"
|
"sha1": "f928dbf7538b3fe8aeeb70fd47ea2641cfddeaf5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"yaml": {
|
"yaml": {
|
||||||
|
|
|
@ -87,41 +87,28 @@ proc typstGen(c: Config): string =
|
||||||
result &= c.applyTemplate(component)
|
result &= c.applyTemplate(component)
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
import hwylterm/[cli, parseopt3]
|
import hwylterm/hwylcli
|
||||||
proc writeHelp() =
|
hwylCli:
|
||||||
echo newHwylCli(
|
name "typstgen"
|
||||||
"[bold]typstgen[/] [[[faint]-h[/]]",
|
flags:
|
||||||
"""
|
config:
|
||||||
typstgen --config typstgen.yml""",
|
T seq[string]
|
||||||
[
|
? "path to config file"
|
||||||
("h", "help", "show this help"),
|
- c
|
||||||
("c","config", "path to config file"),
|
* @["typstgen.yml"]
|
||||||
("","check", "load config and exit"),
|
check:
|
||||||
]
|
T bool
|
||||||
)
|
? "load config and exit"
|
||||||
var
|
run:
|
||||||
p = initOptParser(longNoVal= @["check"])
|
for f in config:
|
||||||
configPath = "typstgen.yml"
|
if not fileExists(f):
|
||||||
check: bool
|
quit($bbfmt("[red]error[/] file: [b]{f}[/] does not exist"))
|
||||||
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
|
|
||||||
|
|
||||||
if not fileExists(configPath):
|
if config.len > 1:
|
||||||
quit($bbfmt("file: [b]{configPath}[/] does not exist"))
|
echo "currently only one config file is considered"
|
||||||
|
|
||||||
let config = loadConfig(configPath)
|
|
||||||
if check: quit 0
|
|
||||||
echo typstGen(config)
|
|
||||||
|
|
||||||
|
let tgConfig = loadConfig(config[0])
|
||||||
|
if check:
|
||||||
|
quit 0
|
||||||
|
|
||||||
|
echo typstGen(tgConfig)
|
||||||
|
|
|
@ -12,4 +12,4 @@ bin = @["typstgen"]
|
||||||
|
|
||||||
requires "nim >= 2.2.0"
|
requires "nim >= 2.2.0"
|
||||||
requires "yaml >= 2.1.1"
|
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