Conversation
As part of the documentation for the install and getting started, we
need to be able to print the version of platform script, and also be
able to run some platform script code. This was suprisingly difficult,
so we want to be able to put in place a system to make adding
commands, specifying their options, and automatically generating help
for them simple.
This uses the "router" strategy where commands are a hierarchy of word
matches, and then the options are like query params for those
matches, so the main dispatch can look like this:
```ts
dispatch(["pls", ...args], {
"pls": [PlsCommand, {
"run :MODULE": RunCommand,
"test FILES...": TestCommand,
}]
});
```
This lets the parent command `PlsCommand` perform any asynchrony it
wants before finally yielding to its "children" which will allow us to
do any global setup, which again, can be async. It also allows us
to add advanced concurrent global options like a `--watch` parameter
that spawns and restarts its children instead of just running them.
At the root is the `PlsCommand` which defines the `--version` options
and `--help` options. There is a single command below the root (for
now) which is the `RunCommand`
The run command accepts a MODULE from either the local file system or
the network, evaluates that module, and then prints out its value.
The docs have been updated to contain the installation process, and a
way to make sure that your installation is working.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
As part of the documentation for the install and getting started, we need to be able to print the version of platform script, and also be able to run some platform script code. There is actually quite a bit of corners to sand down in order to actually have what we represent that we in the docs.
Approach
This puts in place a system to make adding commands, specifying their options, and automatically generating help for them simple. It uses the "router" strategy where commands are a hierarchy of word matches, and then the options are like query params for those matches, so the main dispatch can look like this:
This lets the parent command
PlsCommandperform any asynchrony it wants before finally yielding to its "children" which will allow us to do any global setup, which again, can be async. It also allows us adding advanced concurrent global options like a--watchparameter that spawns and restarts its children instead of just running them. From the parents perspective, the children are just an operation.TODOs and Open Questions
plsexecutable should output YAML, not JSON #51 so that the hello world program prints yaml and not JSON.plswhat its version is #73 so that we aren't "faking" a version in the output.pls.pubso that the examples works from the network.Screenshots