Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tools for creating user-friendly command-line prompt?

I notice that some programs (e.g. sqlite, mysql client) provide a command-line prompt that is very similar in capabilities to the bash's, including:

  • line editing with left and right arrows, delete, insert, ^K, etc.
  • history browsing with up and down arrows
  • ^R for reverse i-search in command history

which make me think that they are using the same toolset for this.

I'd like to create a prompt with similar capabilities in my program, which tools can I use? I prefer it to have the same functionality as in bash, so that the users would be familiar with it.

like image 602
davka Avatar asked Feb 03 '11 15:02

davka


People also ask

What are the CLI tools?

CLI is a command line program that accepts text input to execute operating system functions. In the 1960s, using only computer terminals, this was the only way to interact with computers. In the 1970s an 1980s, command line input was commonly used by Unix systems and PC systems like MS-DOS and Apple DOS.

How do I create a command line tool?

Create a file index. js in the root of the project. This will be the main entry of the CLI tool that will initialize the commands it will have. NOTE: If you are using Windows for development, make sure that the line end character is set to LF instead of CRLF or the tool will not work.


1 Answers

Most of these use the GNU readline library

like image 189
Hasturkun Avatar answered Sep 27 '22 22:09

Hasturkun