Shell: Tab completes every word of a command, and * and ? stand for several files (#67)
CI / build (pull_request) Successful in 1m38s
Site / build (pull_request) Successful in 9s

Tab used to complete a command's first word only. It now follows the help
text word by word: `lora st` gives `lora status`, `gnss track ` lists
`start  stop`. The words are read from the help text as written, so a new
command completes with no table to keep; the Shell's own words are added in
the same notation.

`*` and `?` in the last part of a path, for ls, du, rm, cp and mv, from the
Shell and both consoles. The command runs once for each name matched, lined
up and run by the main loop as each finishes; `cancel` empties the line-up.
64 matches at most, refused whole past that. In the Shell, rm with a pattern
asks once, with the count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
This commit is contained in:
2026-10-07 12:47:10 +02:00
co-authored by Claude Opus 5.5
parent d17d10948d
commit 0fdbb5b1ed
16 changed files with 368 additions and 112 deletions
+6 -3
View File
@@ -30,9 +30,11 @@ class ShellApp : public App {
// A folder's entries that start with `prefix`, whatever their case, a folder's with a slash at its
// end: what Tab completes a path from. `more` when there were too many to give them all.
using List = std::function<std::vector<std::string>(const std::string& folder, const std::string& prefix, bool& more)>;
// How many names a pattern matches (/notes/*.txt), for the question `rm` asks; `more` past the limit.
using Count = std::function<int(const std::string& pattern, bool& more)>;
ShellApp(Run run, Probe probe, List list, const char* helpText, AppManager& apps)
: run_(std::move(run)), probe_(std::move(probe)), list_(std::move(list)), helpText_(helpText), apps_(apps) {}
ShellApp(Run run, Probe probe, List list, Count count, const char* helpText, AppManager& apps)
: run_(std::move(run)), probe_(std::move(probe)), list_(std::move(list)), count_(std::move(count)), helpText_(helpText), apps_(apps) {}
void onEnter() override;
void onExit() override;
@@ -49,10 +51,11 @@ class ShellApp : public App {
Run run_;
Probe probe_;
List list_;
Count count_;
const char* helpText_;
AppManager& apps_;
ShellLog log_;
std::vector<std::string> words_; // the commands Tab completes: built on entering, from `help`
std::string ownHelp_; // the Shell's own commands and the keys `key` takes, in the form of `help`'s text
LineEditor input_{240};
InputHistory history_{16};
std::unique_ptr<DialogModel> confirm_;