mirror of
https://github.com/daylinmorgan/hwylterm.git
synced 2024-11-16 06:28:32 -06:00
abstractions!
This commit is contained in:
parent
5ee8117e96
commit
0bce099520
3 changed files with 36 additions and 8 deletions
|
@ -11,11 +11,8 @@
|
|||
|
||||
|
||||
import std/[enumerate, os, strutils, sequtils, sets, terminal]
|
||||
|
||||
template canImport(x): bool = compiles: import x
|
||||
when not canImport(illwill): {.fatal: "hwylterm/choose requires illwill >= 0.4.1".}
|
||||
import illwill
|
||||
|
||||
import ./private/tryImport
|
||||
tryImport(illwill, "hwylterm/choose requires illwill >= 0.4.1")
|
||||
|
||||
proc exitProc() {.noconv.} =
|
||||
illwillDeInit()
|
||||
|
@ -131,6 +128,31 @@ proc choose*[T](things: openArray[T], height: Natural = 6): seq[T] =
|
|||
|
||||
|
||||
when isMainModule:
|
||||
# import std/parseopt
|
||||
# var
|
||||
# posArgs: seq[string]
|
||||
# style: string
|
||||
# showDebug: bool
|
||||
# var p = initOptParser()
|
||||
# for kind, key, val in p.getopt():
|
||||
# case kind
|
||||
# of cmdEnd:
|
||||
# break
|
||||
# of cmdShortOption, cmdLongOption:
|
||||
# case key
|
||||
# of "help", "h":
|
||||
# writeHelp()
|
||||
# of cmdArgument:
|
||||
# strArgs.add key
|
||||
# for arg in strArgs:
|
||||
# let styled =
|
||||
# if style != "":
|
||||
# arg.bb(style)
|
||||
# else:
|
||||
# arg.bb
|
||||
# echo styled
|
||||
# if showDebug:
|
||||
# echo debug(styled)
|
||||
let items = LowercaseLetters.toSeq()
|
||||
let item = choose(items)
|
||||
echo "selected: ", item
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
|
||||
Adapter to add hwylterm colors to cligen output.
|
||||
]##
|
||||
|
||||
import std/[tables]
|
||||
import ./bbansi
|
||||
template canImport(x): bool = compiles: import x
|
||||
when not canImport(cligen): {.fatal: "hwylterm/cli requires cligen>= 1.7.5".}
|
||||
import cligen
|
||||
import ./private/tryImport
|
||||
tryImport(cligen, "hwylterm/cli requires cligen>= 1.7.5")
|
||||
|
||||
|
||||
type
|
||||
|
|
6
src/hwylterm/private/tryImport.nim
Normal file
6
src/hwylterm/private/tryImport.nim
Normal file
|
@ -0,0 +1,6 @@
|
|||
template tryImport*(x, msg) =
|
||||
const importable = compiles: import x
|
||||
when not importable:
|
||||
{.fatal: msg}
|
||||
else:
|
||||
import x
|
Loading…
Reference in a new issue