main.bend source
main.bend on the hub · documented module
# bolt: a linter, checker and language server for Bend 2.## The one binary. Shake parses the line: `check`, or a word that is no# subcommand, or nothing, lints the files named after it (every `.bend` file# under the current directory when none are); `format` formats them, or with# `--check` lists the ones it would; `lsp` serves an editor over stdio (and# runs Bend's checker on its files); `help` (or `--help`) prints usage;# `--version` prints the release and the short commit when the build has# one. Build it native (`bend main.bend -o bin/bolt.bin`). `bolt lsp` runs on# the cores: with no runtime `--gpu` it is `+RTS --gpu off -RTS lsp`, and# `+RTS --gpu on -RTS` or `+RTS --gpu 4GB -RTS` asks for the device. Runtime# options go between `+RTS` and `-RTS` (bend 2.0.38); bolt declares no# `--gpu` of its own, so `bolt --gpu off` is an unknown option. What the line# does is Args.out's decision (src/LAWS.bend proves it); this file only does# it, and LAWS.bend states what src/stop.bend's say and leave do.# Everything under src/ is internal.import Baseimport ./src/args.bend as Argsimport ./src/lint.bend as Lintimport ./src/fmt/run.bend as FmtRunimport ./src/lsp/run.bend as Lspimport ./src/stop.bend as Stop# what a subcommand runs, over the files after itdef dispatch(cmd: Args.Cmd, paths: List<&2, String>) -> IO(Unit): # noqa: L001 IO driver match cmd: case Args.CCheck{}: Lint.run(paths) case Args.CLsp{}: Lsp.run() case Args.CFormat{check}: FmtRun.run(check, paths)# what a parsed line does, donedef perform(o: Args.Out) -> IO(Unit): # noqa: L001 IO driver match o: case Args.Stop{to, text, code}: do IO<Unit>: Stop.say(to, text) Stop.leave(code) case Args.Go{cmd, paths}: dispatch(cmd, paths)def main() -> IO(Unit): # noqa: L001 IO entry point do IO<Unit>: +av : List<&2, String> <- Args.argv() perform(Args.out(Args.parse(Args.line(av))))