Shell: only its own replies, Apps by their names, and rm as Unix has it (#67)
CI / build (pull_request) Successful in 1m38s
Site / build (pull_request) Successful in 10s

The Shell shows the replies to its own commands and nothing else. The
console knows who each line is printed for (Console::As, Console::origin):
a command run from the Shell prints as the Shell's, and what answers it
later from another task carries that along (ls, tasks, du, cp, update
check, sd list, screenshot, gemini get). Ctrl+b shows everything instead.
This replaces the ten-second window, which was a guess.

An App's name with a capital opens it (Notes, Irc, Wifi, Gnss, Gemini, Lora,
Storage, Shell, System, Settings), from the Shell and from the consoles.

rm needs -r for a folder, here and over the consoles. In the Shell a file,
or a folder with something in it, is asked about unless -f; an empty folder
with -r goes without a word.

The Shell now hands its line to the main loop to run: run from inside the
key handler, rm on a folder overflowed the loop's stack and crashed the
device. `info` says which App is in front.

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 11:35:29 +02:00
co-authored by Claude Opus 5.5
parent 3863d28593
commit 7b5df713ad
24 changed files with 414 additions and 124 deletions
+3 -2
View File
@@ -329,12 +329,13 @@ inline constexpr KeyHelp kShell[] = {
{"Tab", "complete the command"},
{"Fn ; .", "lines you typed before"},
{"Alt ; .", "scroll back, forward"},
{"Ctrl b", "all output, or only yours"},
{"Ctrl b", "your replies only, or all"},
{"Fn , /", "move the cursor"},
{"Del", "delete backwards"},
{"help", "every command"},
{"clear", "an empty screen"},
{"rm -f", "delete without being asked"},
{"Notes", "an App, by its name"},
{"rm -rf", "delete without being asked"},
{"quit `", "leave the Shell"},
};
+13
View File
@@ -82,6 +82,19 @@ void AppManager::handleKey(const KeyEvent& event) {
if (!consumed && event.key == Key::Back) home();
}
std::string AppManager::commandFor(const char* id) {
std::string command;
for (const char* p = id; *p && *p != '-'; p++) command += *p;
if (!command.empty() && command[0] >= 'a' && command[0] <= 'z') command[0] = static_cast<char>(command[0] - 'a' + 'A');
return command;
}
const AppInfo* AppManager::byCommand(const std::string& command) const {
for (auto& info : apps_)
if (!info.hidden && commandFor(info.id) == command) return &info;
return nullptr;
}
const char* AppManager::foregroundTitle() const {
for (auto& info : apps_)
if (info.app == foreground_) return info.title;
+8
View File
@@ -1,5 +1,6 @@
#pragma once
#include <string>
#include <vector>
#include "app.h"
@@ -34,6 +35,13 @@ class AppManager {
void handleKey(const KeyEvent& event);
void update(uint32_t nowMs) { foreground_->update(nowMs); }
// The command that opens an App from the consoles and the Shell (issue #67): its id with a
// capital letter, up to the first dash. "notes" is Notes, "wifi-tools" is Wifi. The capital says
// "an App", where every command of the firmware is in small letters.
static std::string commandFor(const char* id);
// The App that command names, among the ones the Launcher lists; nullptr if there's none.
const AppInfo* byCommand(const std::string& command) const;
App& foreground() const { return *foreground_; }
const char* foregroundTitle() const; // nullptr for the Launcher