Skip to content

Commit 474c10a

Browse files
committed
PR feedback
Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
1 parent 4081945 commit 474c10a

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

examples/README.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Examples
22

3-
This example is composed of two different but equal ways for composing two example components together
4-
* using the `wac` CLI
3+
This example is composed of three different but equal ways for composing two example components together
4+
* two ways using the `wac` CLI
55
* using the `wac-graph` library crate
66

77
The example uses two input components (both located in the `deps` directory) that will be composed together:
@@ -34,22 +34,32 @@ world root {
3434

3535
The resulting composed component will therefore only have the exported `greet` function originally from the `greeter` component.
3636

37-
## CLI
37+
## `wac encode`
3838

3939
`wac` can be used as a CLI tool. The `wac encode` command takes a wac script as input which defines how two components are composed together.
4040

4141
Running the following command should produce a new component that is the composition of the `hello` and `greeter` components.
4242

43+
```bash
44+
wac encode script.wac -o composed.wasm
4345
```
44-
wac encode composition.wac -o composed.wasm
45-
```
4646

47-
*Note*: `wac encode` expects to find any input components inside of a `deps` folder in a directory named after the namespace part of the input component's name. In our example, the wac script uses the `example:greeter` and `example:hello` input components so `wac encode` expects to find those components in the `deps/example` directory.
47+
*Note*: `wac encode` expects to find any input components inside of a `deps` folder in a directory named after the namespace part of the input component's name (however, this is configurable with the `--deps-dir` option). In our example, the wac script uses the `example:greeter` and `example:hello` input components so `wac encode` expects to find those components in the `deps/example` directory.
48+
49+
## `wac plug`
50+
51+
`wac` also comes with an opinionated CLI option called `wac plug` which will "plug" the exports of one component (the "plug") into equivalently named imports of another component (the "socket").
52+
53+
In this example, we can do this with the following invocation:
54+
55+
```bash
56+
wac plug --plug deps/example/hello.wasm deps/example/greeter.wasm -o composed.wasm
57+
```
4858

4959
## Programmatic Graph API
5060

5161
You can also build the composition using the programmatic API used by the `programmatic` example binary. This can be done by running the following inside the `programmatic` directory:
5262

53-
```
54-
$ cargo run
63+
```bash
64+
cargo run
5565
```

0 commit comments

Comments
 (0)