ovs-appctl-comp: Refine the master for ovs-appctl completion.

After the hackathon, the best design for the ovs-appctl completion
seems to be as follow:

1. An extraction script extracts the sub-commands and options from
   the manpage.
2. A helper script which takes the command line string so far as
   input and returns the all available completions.
3. A generic compgen function that invokes the helper script/

Signed-off-by: Yeqiao Wang <ee07b291@gmail.com>
ovs_appctl_compgen: Put all logic into one file.

Signed-off-by: Yeqiao Wang <ee07b291@gmail.com>
Update README.md

Add usage and example to README.md

Signed-off-by: Yeqiao Wang <ee07b291@gmail.com>
ovs_appctl_compgen: Fix a bug.

Some subcommand combination format has prefix * to indicate optional
argument.  Two match this scenario we need a separate awk command.

A long term solution should be redesign to the extraction format.

Signed-off-by: Yeqiao Wang <ee07b291@gmail.com>
Update README.md

Fix the README.md example.

Signed-off-by: Yeqiao Wang <ee07b291@gmail.com>
ovs_appctl_compgen: Fix an unfixed bug.

Commit 33e5a9687b (ovs_appctl_compgen: Fix a bug.) did not fix the
bug, this commit does.

Signed-off-by: Yeqiao Wang <ee07b291@gmail.com>
ovs_appctl_compgen: Add a hacky optimization.

Currently, completion for commands like "stp/tcn [bridge]" is
confusing (hard to explain, please rollback and try~).

This commit makes it look better.

Signed-off-by: Yeqiao Wang <ee07b291@gmail.com>
Update README.md

Add requirement of ovs installment.

Signed-off-by: Yeqiao Wang <ee07b291@gmail.com>
ovs_appctl_compgen: Solved a very big issue.

With compgen, user needs to press [tab] twice to get the completion
of a new argument.  The first press of [tab] will not show anything.
However, since the current script contains several 'printf' to stdout,
the first press of [tab] will cause the print of those helping
messages.  This can be very confusing!

To avoid this, I found that the compgen fills in different values in
the $COMP_TYPE for each [tab] pressed, 9 and 63, respectively.
Although I need to investigate further about the meaning of COMP_TYPE
code, $COMP_TYPE can be used as indicator to suppress the 'printf'
output at first [tab].

So, this commit takes advantage of $COMP_TYPE and makes the compgen
function only print to stdout at second [tab] execution.

NOTE:
- It is hacky, but I'm super happy!

Signed-off-by: Yeqiao Wang <ee07b291@gmail.com>
Update README.md

Update the README.md, since it is much fancier.~

Signed-off-by: Yeqiao Wang <ee07b291@gmail.com>
ovs_appctl_compgen: Refine comments.

Signed-off-by: Yeqiao Wang <ee07b291@gmail.com>
ovs_appctl_compgen: Fix a confusing output.

This commit adds a check so that when the input does not match any
possible completion, the no helper messages are printed.

Signed-off-by: Yeqiao Wang <ee07b291@gmail.com>
ovs_appctl_compgen: Makes the ovs-appctl compgen script generic.

This commit makes the completion script more generic.  Basically, it
detects all possible target daemons for ovs-appctl and allows completion
script to extract subcommands for each type of daemon.

Signed-off-by: Yeqiao Wang <ee07b291@gmail.com>
ovs_appctl_compgen: Fix two bugs.

A typo in arg_to_kword() and a bug in parse_and_compgen().

Signed-off-by: Yeqiao Wang <ee07b291@gmail.com>
Update README.md

Signed-off-by: Yeqiao Wang <ee07b291@gmail.com>