mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-10-17 10:55:06 +00:00
app-module - Apps now have support for: - environment variables (inherit from parent app) - current workdir - window size (when running in terminal) - Add type aliases like `AppId` and `PackageId` - Remove data duplication between ledger and app instance records: create `AppManifestSet` - `AppManifest` usage safety improved: pass by value where needed, or use `AppId` instead of a manifest. Terminal and shell - Moved shell commands into coreutils-module as proper apps. - Refine stack size for terminal and shell because apps now run with their own task and stack (including in-memory apps) Platform - Fix for listing root dir on ESP32: wrap posix directory functions and wire in file systems. - Moved all platform-specific file system init code to platform subprojects Other - Fix for screenshot capture (issue with paths) - Fixes for coreutils app correctness - Memory optimizations (use more PSRAM where possible) in various locations such as app-module, shell and terminal. - `ls` and `help` commands now use terminal width and show columns of data by default - Created fs helpers at `TactilityKernel/include/tactility/filesystem/fs.h` (partially ported from `ShellFs`)
47 lines
1.3 KiB
C++
47 lines
1.3 KiB
C++
#include <coreutils/command_support.h>
|
|
|
|
#include <app/manager.h>
|
|
#include <app/manifest.h>
|
|
|
|
#include <cstdio>
|
|
|
|
/* Reports where a command comes from: a shell builtin, a bundled binary, or nothing. */
|
|
namespace coreutils::which {
|
|
|
|
static int32_t main(int argc, char* argv[]) {
|
|
if (argc < 2) {
|
|
printf("Usage: which <command>...\n");
|
|
return 1;
|
|
}
|
|
|
|
int status = 0;
|
|
for (int i = 1; i < argc; i++) {
|
|
AppManifest manifest {};
|
|
const bool is_registered = app_manager_find_manifest(argv[i], &manifest) == ERROR_NONE
|
|
&& (manifest.flags & APP_MANIFEST_FLAG_HEADLESS) != 0;
|
|
if (is_registered) {
|
|
if (manifest.location.type == APP_LOCATION_MEMORY) {
|
|
puts("builtin");
|
|
} else {
|
|
puts(static_cast<const char*>(manifest.location.location));
|
|
}
|
|
} else {
|
|
fprintf(stderr, "which: no %s found\n", argv[i]);
|
|
status = 1;
|
|
}
|
|
}
|
|
|
|
return status;
|
|
}
|
|
|
|
extern const ::AppManifest manifest = {
|
|
.id = "which",
|
|
.name = "which",
|
|
.category = APP_CATEGORY_SYSTEM,
|
|
.location = { .type = APP_LOCATION_MEMORY, .location = reinterpret_cast<void*>(main) },
|
|
.flags = APP_MANIFEST_FLAG_HIDDEN | APP_MANIFEST_FLAG_HEADLESS,
|
|
.stack = { .depth = 3072, .desired_memory_capability = 0 },
|
|
};
|
|
|
|
} // namespace coreutils::which
|