Skip to content

Add run command and documentation#62

Merged
cowboyd merged 1 commit intomainfrom
cl/pls-run
Feb 9, 2023
Merged

Add run command and documentation#62
cowboyd merged 1 commit intomainfrom
cl/pls-run

Conversation

@cowboyd
Copy link
Copy Markdown
Member

@cowboyd cowboyd commented Jan 19, 2023

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:

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 adding advanced concurrent global options like a --watch parameter 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

Screenshots

demonstration of the bare-bones CLI

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.
@cowboyd cowboyd marked this pull request as ready for review February 7, 2023 15:10
@cowboyd cowboyd requested a review from a team February 7, 2023 15:14
Copy link
Copy Markdown
Member

@taras taras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@cowboyd cowboyd merged commit e3d16b0 into main Feb 9, 2023
@cowboyd cowboyd deleted the cl/pls-run branch February 9, 2023 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pls executable should output YAML, not JSON a bare bit of yaml as a module should evaluate to itself.

2 participants