Phase 4: commands in Bjolang

- A package of user commands in $XDG_CONFIG_HOME/bjosh/commands. Its
  module commands.bjo exports bjosh-extension: value commands, shell
  commands and a prompt function.
- (bjosh api): the types and functions a package imports.
- (bjosh user): builds the package when it is stale, and loads it with
  (std plugin) at each start. `reload` builds and loads it again.
- bjosh --new-commands writes a package with an example.
- No Native AOT, because it cannot load modules. bin/bjosh starts
  src/main.exe.
- tests/extension.bjo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Linus Björnstam 2026-12-01 10:38:40 +01:00
parent f8c4ad64bc
commit 84bd2f3382
11 changed files with 686 additions and 29 deletions

View file

@ -10,8 +10,8 @@ non-trivial functions. No essays.
## This package
- `bjo build` builds the shell: `src/main.exe`, and the native
`src/main` (`(aot #t)`).
- `bjo build` builds the shell: `src/main.exe`. `bin/bjosh` starts it with
dotnet. No Native AOT: it cannot load the user's commands.
- `bjo test` runs the tests. `tests/run.bjo` and `tests/interactive.bjo`
run `src/main.exe`, so run `bjo build` first.
- It depends on bjoterm at `../bjoterm`. A change there needs `bjo build`
@ -27,9 +27,18 @@ non-trivial functions. No essays.
- `(bjosh commands)`: the value commands, and their table.
- `(bjosh pipeline)`: value commands next to each other, as one unit.
- `(bjosh editor)`: when Enter runs a line, and the completer.
- `(bjosh api)`: what a package of user commands imports: `Extension`,
`ShellCommand`, `ShellView`.
- `(bjosh user)`: builds and loads the package of user commands, in
`$XDG_CONFIG_HOME/bjosh/commands`, with `(std plugin)`.
- Tests:
- `tests/syntax.bjo`, `tests/expand.bjo`, `tests/editor.bjo`: unit tests.
- `tests/run.bjo`: lines through `bjosh -c`, a file, and stdin.
- `tests/values.bjo`: the value commands through `bjosh -c`.
- `tests/interactive.bjo`: job control, the prompt and the start-up
file under `script`.
- `tests/extension.bjo`: user commands and their prompt, in a package
that the test writes.
- The tests that run bjosh with `-c` load the user commands of your own
`XDG_CONFIG_HOME`, when there are any. `tests/extension.bjo` and
`tests/interactive.bjo` set it to a directory of their own.