2023-08-21 23:08:56 -07:00
|
|
|
package gay.pizza.pork.cli
|
|
|
|
|
|
|
|
import com.github.ajalt.clikt.core.CliktCommand
|
|
|
|
import com.github.ajalt.clikt.parameters.arguments.argument
|
|
|
|
import com.github.ajalt.clikt.parameters.types.path
|
|
|
|
import gay.pizza.pork.eval.CallableFunction
|
|
|
|
import gay.pizza.pork.eval.Scope
|
2023-08-22 19:54:21 -07:00
|
|
|
import gay.pizza.pork.frontend.FileFrontend
|
2023-08-21 23:08:56 -07:00
|
|
|
|
|
|
|
class RunCommand : CliktCommand(help = "Run Program", name = "run") {
|
|
|
|
val path by argument("file").path(mustExist = true, canBeDir = false)
|
|
|
|
|
|
|
|
override fun run() {
|
2023-08-22 19:54:21 -07:00
|
|
|
val frontend = FileFrontend(path)
|
2023-08-21 23:08:56 -07:00
|
|
|
val scope = Scope()
|
|
|
|
scope.define("println", CallableFunction { arguments ->
|
|
|
|
for (argument in arguments.values) {
|
|
|
|
println(argument)
|
|
|
|
}
|
|
|
|
})
|
2023-08-22 19:54:21 -07:00
|
|
|
frontend.evaluate(scope)
|
2023-08-21 23:08:56 -07:00
|
|
|
}
|
|
|
|
}
|