feat: add support for shell builtins to command completion

This commit is contained in:
2026-06-16 18:41:56 +02:00
parent f616bf6a86
commit 4261212913
4 changed files with 34 additions and 1 deletions
+16
View File
@@ -6,6 +6,7 @@
#include <montauk/string.h>
#include <montauk/syscall.h>
#include "shell.h"
#define RD_MAX 128
@@ -58,6 +59,7 @@ int get_completions( // returns no. of results
int arrayMax
) {
// --- System commands (0:/os/*.elf) ----
const char* names[RD_MAX] = { };
int n = montauk::readdir("0:/os", names, RD_MAX);
@@ -89,5 +91,19 @@ int get_completions( // returns no. of results
}
}
// ---- Shell builtins ----
size_t builtins_count = sizeof(shell_builtins) / sizeof(const char*);
for (size_t i = 0; i < builtins_count; i++) {
if (montauk::starts_with(shell_builtins[i], (const char*)string)) {
if (r > arrayMax)
break;
array[r] = (char *)shell_builtins[i];
r++;
}
}
return r;
}