Add del alias for rm helper command

This commit is contained in:
Joe Tretter
2026-05-05 20:12:08 -05:00
parent b8c4096123
commit 5c7c7ad29d
4 changed files with 20 additions and 7 deletions

View File

@@ -104,7 +104,7 @@ object GitSandboxEngine {
" mkdir|md <directory>",
" cd <directory>",
" cd..",
" rm <file>",
" rm|del <file>",
" echo <message>",
)
@@ -119,7 +119,7 @@ object GitSandboxEngine {
else repo.copy(files = repo.files + GitFile(name = name)) to emptyList()
}
(parts[0] == "mkdir" || parts[0] == "md") && parts.size >= 2 -> repo to emptyList()
parts[0] == "rm" && parts.size >= 2 -> {
(parts[0] == "rm" || parts[0] == "del") && parts.size >= 2 -> {
val target = parts[1]
repo.copy(files = repo.files.mapNotNull { file ->
when {

View File

@@ -84,7 +84,7 @@ class GitRepositoryRuntime(private val context: Context) {
add("Native Git prototype:")
add(" binary path: nativeLibraryDir/libgit.so")
add(" selected ABI: ${Build.SUPPORTED_ABIS.firstOrNull() ?: "unknown"}")
add(" helper commands: ls/dir, pwd, cat, touch, mkdir/md, cd.., rm, echo")
add(" helper commands: ls/dir, pwd, cat, touch, mkdir/md, cd.., rm/del, echo")
add(" visual editors: vi, nano, emacs, ed, ex")
add(" git help <command>")
}
@@ -240,13 +240,13 @@ class GitRepositoryRuntime(private val context: Context) {
}
}
}
"rm" -> {
"rm", "del" -> {
val targets = tokens.drop(1)
if (targets.isEmpty()) return currentRepo to listOf("usage: rm <path>")
val errors = targets.mapNotNull { target ->
val file = File(workingDir, target)
if (!file.exists()) {
"rm: $target: No such file or directory"
"${tokens.first()}: $target: No such file or directory"
} else {
file.deleteRecursively()
null