Technical Architecture: Shell Autocompletion
Overview
This technical architecture document describes the design of subcommand-level help dispatch in C++23 and the completion generator logic in Bash.
C++23 Subcommand Help Dispatch
In src/app.cpp, App::run() checks for -h or --help in subcommand argument vectors before executing command logic:
bool is_help_requested(const std::vector<std::string> &args) {
for (const auto &arg : args) {
if (arg == "-h" || arg == "--help") {
return true;
}
}
return false;
}
When is_help_requested() is true, execution routes to dedicated help functions:
print_login_help()print_chat_help()print_msg_help()print_send_help()print_topic_help()
Bash Autocompletion Engine
File: completions/grm.bash
The script hooks into Bash completion via complete -F _grm_completions grm:
Top-Level Commands: Completes
login,chat,msg,send,topic, and global flags (-h,--help,-V,--version,-v,--verbose,-d,--debug,-q,--quiet,-c,--config).Subcommands & Flags:
grm login$rightarrow$-p,--phone,-k,--codegrm chat$rightarrow$lsgrm msg$rightarrow$ls,export,searchgrm msg export <chat_id>$rightarrow$csv,jsongrm send$rightarrow$filegrm send file$rightarrow$-C,--caption,-t,--topicgrm topic$rightarrow$ls