Remove Kotlin interactive-add emulation and run patch add via the native Git runtime with PTY-backed session IO.
47 lines
1.4 KiB
Kotlin
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)
|
|
}
|
|
}
|