No description
Find a file
2019-11-10 19:23:32 +01:00
docs updated readme and docs 2019-11-10 18:38:40 +01:00
src enable input without clearing screen 2019-11-10 19:23:32 +01:00
tests allow empty string for getInput 2019-11-10 18:20:19 +01:00
.travis.yml added travis ci 2019-11-05 14:11:54 +01:00
cli_menu.nimble enable input without clearing screen 2019-11-10 19:23:32 +01:00
README.md updated readme and docs 2019-11-10 18:38:40 +01:00

cli_menu Build Status

A library to create interactive commandline menus without writing boilerplate code.

Usage

There are different menu types that can be used.
These are just some examples. To learn about all functions read the docs.


subMenus

Used to select subfunctions or submenus.
You need to specify a menu title and a sequence of tuples. Each tuple contains a string describing the option and the function that should be called when the option is selected.

The example:

    subMenus("test",@[
        ("option a",subMenuA),
        ("option b",subMenuB)
        ])

creates the output:

 test
   1) option a
   2) option b
   Q) quit
 choose: 

selectMenu

Asks the user to select one of the given options.
The function checks if the user input is valid for the amount of options and returns the input if corret. If the input is incorrect the user is notified and asked to enter a new input. If the user quits -1 is returned.

You need to specify a menu title and a sequence of strings describing the options.

example:

   subMenus("test",@["option a","option b"])

creates the output

   test
   1) option a
   2) option b
   Q) quit
   choose: 

getUserInput

Asks the user to input something and then checks the input.

example:

import os
# getUserInput(title,prompt,error: string, check: proc(x: string):bool)
let input = getUserInput("Select a file to hide.","Filename","not a valid file",existsFile)

creates the output:

  Select a file to hide.
  Filename: 

The checkFunction must have a single string argument and the return type boolean. In this example the proc existsFile from the os module is used to check if the user entered a valid filepath
If the input is invalid the user is notified with the error string and asked for new input. Empty input is always accepted.


Docs