Use readline library to built command line tools

Use readline library to built command line tools

Table of Contents

  • 1 Why readline library?
  • 2 How to use it?

1 Why readline library?

As a Linux programmer, I always need to write some command line tools, with the help of GNU Readline library, this mission can be a snap.

So what's the readline library gives for us, according to its official document? It provides a set of functions which allow users to edit command lines as they typed in. What's more, it also supports history recording and auto-completion.

It is GNU software and is distributed under the terms of GPL license.

2 How to use it?

I upload my source code, using the readline library, which implemented a silly command line tools with only two command inside – help and quit, but I can add another command easily in its framework. It support history recoding, which means you can browser the your command history by up/down keys, but it still cann't support command auto-completion(I will add this function which is natively supported by readline, and the uses just need to type the Tab key to trigger auto-completion.).

All of those was inspired by the bluez's bluetoothctl command line tool. Following is its source code link.
https://github.com/suzp1984/parrot/tree/master/C/readline

Should I give it a brighting and resounding name?

Comments

Popular posts from this blog

Bluedroid stack in android

How to setup a NAT server?

Network programming in elisp