Add exercise description onboarding bubble
Remove duplicate IME padding that caused keyboard gap Add md alias for mkdir helper command Add dir alias for ls helper command Add cd.. shortcut for cd .. helper command
This commit is contained in:
@@ -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, pwd, cat, touch, mkdir, rm, echo")
|
||||
add(" helper commands: ls/dir, pwd, cat, touch, mkdir/md, cd.., rm, echo")
|
||||
add(" visual editors: vi, nano, emacs, ed, ex")
|
||||
add(" git help <command>")
|
||||
}
|
||||
@@ -193,7 +193,7 @@ class GitRepositoryRuntime(private val context: Context) {
|
||||
|
||||
private fun executeHelperCommand(sandboxRoot: File, workingDir: File, currentRepo: RepoState, tokens: List<String>): Pair<RepoState, List<String>> {
|
||||
return when (tokens.first()) {
|
||||
"ls" -> currentRepo to workingDir.listFiles()
|
||||
"ls", "dir" -> currentRepo to workingDir.listFiles()
|
||||
?.filterNot { it.name == ".git" }
|
||||
?.sortedBy { it.name }
|
||||
?.map { it.name }
|
||||
@@ -218,7 +218,7 @@ class GitRepositoryRuntime(private val context: Context) {
|
||||
currentRepo to emptyList()
|
||||
}
|
||||
}
|
||||
"mkdir" -> {
|
||||
"mkdir", "md" -> {
|
||||
val target = tokens.getOrNull(1) ?: return currentRepo to listOf("usage: mkdir <dir>")
|
||||
val dir = File(workingDir, target)
|
||||
if (dir.exists()) currentRepo to listOf("mkdir: $target: File exists") else {
|
||||
@@ -226,8 +226,9 @@ class GitRepositoryRuntime(private val context: Context) {
|
||||
currentRepo to emptyList()
|
||||
}
|
||||
}
|
||||
"cd" -> {
|
||||
val target = tokens.getOrNull(1) ?: return currentRepo to listOf("usage: cd <dir>")
|
||||
"cd", "cd.." -> {
|
||||
val target = if (tokens.first() == "cd..") ".." else tokens.getOrNull(1)
|
||||
?: return currentRepo to listOf("usage: cd <dir>")
|
||||
val dir = File(workingDir, target).canonicalFile
|
||||
when {
|
||||
!dir.exists() -> currentRepo to listOf("cd: $target: does not exist")
|
||||
|
||||
Reference in New Issue
Block a user