Add del alias for rm helper command
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user