generated from rnentjes/kotlin-server-web-undertow
Remove legacy JVM-specific file system, shell, and related implementations; migrate to platform-agnostic and common main modules.
This commit is contained in:
38
src/commonMain/kotlin/mtmc/os/shell/builtins/SpeedCommand.kt
Normal file
38
src/commonMain/kotlin/mtmc/os/shell/builtins/SpeedCommand.kt
Normal file
@@ -0,0 +1,38 @@
|
||||
package mtmc.os.shell.builtins
|
||||
|
||||
import mtmc.emulator.MonTanaMiniComputer
|
||||
import mtmc.os.shell.ShellCommand
|
||||
import mtmc.tokenizer.MTMCToken
|
||||
import mtmc.tokenizer.MTMCTokenizer
|
||||
|
||||
class SpeedCommand : ShellCommand() {
|
||||
private val speeds = listOf(
|
||||
1, 10, 100, 1000, 10000, 100000, 1000000
|
||||
)
|
||||
|
||||
@Throws(Exception::class)
|
||||
override fun exec(tokens: MTMCTokenizer, computer: MonTanaMiniComputer) {
|
||||
if (tokens.match(MTMCToken.TokenType.IDENTIFIER)) {
|
||||
computer.speed = 0
|
||||
} else if (tokens.match(MTMCToken.TokenType.INTEGER)) {
|
||||
val speed = tokens.consumeAsInteger()
|
||||
if (!speeds.contains(speed)) {
|
||||
usageException()
|
||||
}
|
||||
computer.speed = speed
|
||||
} else {
|
||||
usageException()
|
||||
}
|
||||
}
|
||||
|
||||
override val help: String
|
||||
get() = """
|
||||
speed <val> - set the speed of the computer
|
||||
where <val> is one of:
|
||||
raw - run with no simulated speed delay
|
||||
1 - run the computer at 1hz
|
||||
10 - run the computer at 10hz
|
||||
100 - run the computer at 100hz
|
||||
1000 - run the computer at 1khz
|
||||
""".trimIndent()
|
||||
}
|
||||
Reference in New Issue
Block a user