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:
Joe Tretter
2026-05-05 20:08:51 -05:00
parent 344ff99f0a
commit b8c4096123
6 changed files with 112 additions and 14 deletions

View File

@@ -95,14 +95,15 @@ object GitSandboxEngine {
fun commandReferenceLines(): List<String> = listOf(
"Available sandbox commands:",
" git ",
" ls",
" ls|dir",
" touch <file>",
" help",
" pwd ",
" cat <file>",
" touch <file>",
" mkdir <directory>",
" mkdir|md <directory>",
" cd <directory>",
" cd..",
" rm <file>",
" echo <message>",
)
@@ -117,7 +118,7 @@ object GitSandboxEngine {
if (repo.files.any { it.name == name && !it.deleted }) repo to listOf("$name already exists")
else repo.copy(files = repo.files + GitFile(name = name)) to emptyList()
}
parts[0] == "mkdir" && parts.size >= 2 -> repo to emptyList()
(parts[0] == "mkdir" || parts[0] == "md") && parts.size >= 2 -> repo to emptyList()
parts[0] == "rm" && parts.size >= 2 -> {
val target = parts[1]
repo.copy(files = repo.files.mapNotNull { file ->
@@ -129,7 +130,8 @@ object GitSandboxEngine {
}) to emptyList()
}
parts[0] == "echo" -> writeEcho(repo, parts)
parts[0] == "ls" -> repo to repo.files.filterNot { it.deleted }.map { it.name }.ifEmpty { listOf() }
parts[0] == "ls" || parts[0] == "dir" -> repo to repo.files.filterNot { it.deleted }.map { it.name }.ifEmpty { listOf() }
parts[0] == "cd.." -> repo.copy(currentDir = parentDirectory(repo.currentDir)) to emptyList()
parts[0] != "git" -> repo to listOf("Command not supported in sandbox. Try a git command or 'touch'.")
parts.size >= 2 && parts[1] == "init" -> repo.copy(initialized = true, branches = mapOf("master" to repo.commits.size)) to listOf("Initialized empty Git repository")
!repo.initialized -> repo to listOf("fatal: not a git repository")
@@ -258,6 +260,11 @@ object GitSandboxEngine {
return repo.copy(files = updatedFiles) to emptyList()
}
private fun parentDirectory(currentDir: String): String {
if (currentDir == ".") return "."
return currentDir.substringBeforeLast('/', missingDelimiterValue = ".").ifBlank { "." }
}
fun expandPathspecs(repo: RepoState, arguments: List<String>): List<String> {
return arguments.flatMap { argument ->
if (!argument.hasGlob()) {