Files
Githug-Android/app/src/main/java/solutions/tretter/githugandroid/GitSandboxEngine.kt
Joe Tretter 943bf03ca0 Route interactive Git through native terminal sessions
Remove Kotlin interactive-add emulation and run patch add via the native Git runtime with PTY-backed session IO.
2026-06-27 13:07:35 -05:00

47 lines
1.4 KiB
Kotlin

package solutions.tretter.githugandroid
object GitSandboxEngine {
data class ShellToken(
val value: String,
val quoted: Boolean = false,
)
fun commandReferenceLines(): List<String> = listOf(
"Available sandbox commands:",
" git ",
" ls|dir",
" touch <file>",
" help",
" pwd ",
" cat <file>",
" touch <file>",
" mkdir|md <directory>",
" cd <directory>",
" cd..",
" rm|del <file>",
" echo <message>",
)
fun execute(repo: RepoState, command: String): Pair<RepoState, List<String>> {
val shellParts = tokenizeShellCommand(command)
if (shellParts.isEmpty()) return repo to emptyList()
return SandboxCommandEngine.execute(repo, shellParts)
}
fun tokenizeCommand(command: String): List<String> {
return SandboxShell.tokenizeCommand(command)
}
fun tokenizeShellCommand(command: String): List<ShellToken> {
return SandboxShell.tokenizeShellCommand(command)
}
fun expandPathspecs(repo: RepoState, arguments: List<String>): List<String> {
return SandboxShell.expandPathspecs(repo, arguments)
}
fun expandPathspecTokens(repo: RepoState, arguments: List<ShellToken>): List<String> {
return SandboxShell.expandPathspecTokens(repo, arguments)
}
}