Closed beshrkayali closed 3 years ago
Name: Loki
Author: Beshr Kayali
Posting: Loki is a small library for writing line-oriented command interpreters (or cli programs) in Nim that is inspired by Python's cmd lib.
Version 0.3 is released this month, and it adds the functionality of automatically generating a TOC and "help" command.
Quick example:
import loki, strutils, options from sequtils import zip loki(myHandler, input): do_greet name: ## Get a nice greeting! if isSome(name): echo("Hello ", name.get, "!") else: echo("Hello there!") do_add num1, num2: if isSome(num1) and isSome(num2): echo("Result is ", parseInt(num1.get) + parseInt(num2.get)) else: echo("Provide two numbers to add them") do_EOF: write(stdout, "Bye!\n") return true default: write(stdout, "*** Unknown syntax: ", input.text , " ***\n") let myCmd = newLoki( handler=myHandler, intro="Welcome to my CLI!\n", ) myCmd.cmdLoop
And an example run: https://asciinema.org/a/iMA7pIq2f7sy8X44pkCPhNmOt
Name: Loki
Author: Beshr Kayali
Posting: Loki is a small library for writing line-oriented command interpreters (or cli programs) in Nim that is inspired by Python's cmd lib.
Version 0.3 is released this month, and it adds the functionality of automatically generating a TOC and "help" command.
Quick example:
And an example run: https://asciinema.org/a/iMA7pIq2f7sy8X44pkCPhNmOt