Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,45 @@ commands; `help` writes usage.

## Install

Use with [Bend](https://github.com/bendlang/bend) or install easily with [ez](https://github.com/Emerging-Patterns/ez):
With [Bend](https://github.com/bendlang/bend) alone there is nothing to
install: import shake by its hub name and `bend` fetches it from
[the hub](https://hub.bend-lang.com) into `~/.bend/lib` on the first run.
`0x085b03c84ca37125e38dddede7b91e55` is shake v0.2.0.

```
import 0x085b03c84ca37125e38dddede7b91e55/main.bend as Shake
```

Or with [ez](https://github.com/Emerging-Patterns/ez), which records the
package in `ez.toml` (`ez init` makes one):

```
ez init
ez add Emerging-Patterns/shake
```

## Usage

A spec, a parse, and a read. `parse` answers `Done` with what the words
bound, or `Fail` with why they could not be bound:

```
import 0xdf41d30432187d983a3c5b9db32d376d/main.bend as Shake
import 0x085b03c84ca37125e38dddede7b91e55/main.bend as Shake

def spec() -> Shake.Cli:
Shake.app("hi", "Say hello.", None{},
[Shake.opt("name", Some{"n"}, Some{"name"}, "Who to greet", False{},
Some{"world"}, [])],
[])

def greet(got: Result<&2, &2, Shake.ParseErr, Shake.Matched>) -> String:
match got:
case Done{mm}:
"hello " ++ Maybe.default(&2, String, Shake.get(mm, "name"), "")
case Fail{ee}:
Shake.err_text(spec(), ee)

def main() -> String:
greet(Shake.parse(spec(), ["--name", "Ada"]))
```

`main.bend` is the whole interface: the types (`Shake.Cli`, `Shake.Sub`,
Expand Down
Loading