Fix aos_dump/aos_send autocomplete w/ zsh
This change add an additional flag to aos_cli_utils which disables
returning <channel> <message type> pairs. I spent a while digging
into the zsh auto-completion subsystem to get it or aos to handle
the pairs correctly and was not able to find a good way to get it
working.
I do also think this gives a slightly more managable auto-complete
list at the command line.
Change-Id: Ia79dddb68db6fe930d5944ad2ee858a1e8d41972
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/aos_cli_utils.cc b/aos/aos_cli_utils.cc
index a4ea95e..bd54e38 100644
--- a/aos/aos_cli_utils.cc
+++ b/aos/aos_cli_utils.cc
@@ -17,6 +17,11 @@
DEFINE_bool(
_bash_autocomplete, false,
"Internal use: Outputs channel list for use with autocomplete script.");
+
+DEFINE_bool(_zsh_compatability, false,
+ "Internal use: Force completion to complete either channels or "
+ "message_types, zsh doesn't handle spaces well.");
+
DEFINE_string(_bash_autocomplete_word, "",
"Internal use: Current word being autocompleted");
@@ -195,7 +200,9 @@
// Otherwise, since the message type is poulated yet not being edited,
// the user must be editing the channel name alone, in which case only
// suggest channel names, not pairs.
- if (message_type.empty()) {
+ // If _split_complete flag is set then dont return
+ // pairs of values
+ if (!FLAGS__zsh_compatability && message_type.empty()) {
std::cout << '\'' << channel->name()->c_str() << ' '
<< channel->type()->c_str() << "' ";
} else {