Working with the console, e.g. read a line from the user.
Procs
proc input(prompt: string = ""): string {....raises: [IOError, EOFError], tags: [WriteIOEffect, ReadIOEffect], forbids: [].}
-
Mimics Python's input() function, i.e. read a line from the stdin.
You can also specify a prompt.
let name = input("Name: ")
proc inputExtra(prompt: string = ""): string {....raises: [EOFError], tags: [ReadIOEffect, WriteIOEffect], forbids: [].}
-
Like Python's input() function. Arrows also work.
You can also specify a prompt. The extra thing is that the arrows also work, like in Bash. In Python you can have the same effect if you import readline. If the user presses Ctrl+C or Ctrl+D, an EOFError exception is raised that you catch on the caller side.
try: let name = input("Name: ") except EOFError: echo "Ctrl+D was pressed"