Compare commits

..

2 commits

Author SHA1 Message Date
be17fc6bc9
todos
Some checks failed
GitHub Pages / build (push) Has been cancelled
GitHub Pages / deploy (push) Has been cancelled
2024-10-08 15:32:32 -05:00
e175cf1fc9
add basic confim util 2024-10-08 15:32:24 -05:00
3 changed files with 27 additions and 2 deletions

View file

@ -10,5 +10,5 @@
]## ]##
import hwylterm/[spin, bbansi] import hwylterm/[spin, bbansi, confirm]
export spin, bbansi export spin, bbansi, confirm

21
src/hwylterm/confirm.nim Normal file
View file

@ -0,0 +1,21 @@
import std/[strutils]
import ./bbansi
proc confirm*(
question: string,
prefix = "",
suffix = ""
): bool =
result = false
stderr.write $(question & bb"[yellow] (Y/n) ")
while true:
let ans = readLine(stdin)
case ans.strip().toLowerAscii():
of "y","yes": return true
of "n","no": return false
else:
stderr.write($bb("[red]Please answer Yes/no\nexpected one of [b]Y,yes,N,no "))
stderr.write "\n"
when isMainModule:
echo "Response: ", confirm("Is it working?")

View file

@ -11,6 +11,7 @@
- [ ] consider reducing illwill surface to only relevant IO (input) features - [ ] consider reducing illwill surface to only relevant IO (input) features
- [ ] revamp spinner api - [ ] revamp spinner api
- [x] add Bbstring ~~indexing operations~~ strutils, that are span aware - [x] add Bbstring ~~indexing operations~~ strutils, that are span aware
- [ ] add a `commands` option for `newHwylCli` in `hwylterm/cli`
## features ## features
@ -22,5 +23,8 @@
- [ ] support for rgb colors - [ ] support for rgb colors
- [ ] modify 256 colors w/parser changes to be `"[color(9)]red"` instead of `[9]red` - [ ] modify 256 colors w/parser changes to be `"[color(9)]red"` instead of `[9]red`
- [x] improve color detection [ref](https://github.com/Textualize/rich/blob/4101991898ee7a09fe1706daca24af5e1e054862/rich/console.py#L791) - [x] improve color detection [ref](https://github.com/Textualize/rich/blob/4101991898ee7a09fe1706daca24af5e1e054862/rich/console.py#L791)
## testing
- [ ] investigate [cap10](https://github.com/crashappsec/cap10) as a means of scripting the testing
<!-- generated with <3 by daylinmorgan/todo --> <!-- generated with <3 by daylinmorgan/todo -->