Skip to content

Commit 2b0052a

Browse files
Merge pull request #133 from rylev/rename-encode
Rename encode to compose
2 parents 2611140 + 80dad09 commit 2b0052a

File tree

6 files changed

+28
-28
lines changed

6 files changed

+28
-28
lines changed

Cargo.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ cargo binstall wac-cli
9999
The `wac` CLI tool has the following commands:
100100

101101
* `wac plug` - Plugs the imports of a component with one or more other components.
102+
* `wac compose` - Compose WebAssembly components using the provided WAC source file.
102103
* `wac parse` - Parses a composition into a JSON representation of the AST.
103104
* `wac resolve` - Resolves a composition into a JSON representation.
104-
* `wac encode` - Encodes a WAC source file as a WebAssembly component.
105105

106106
### Quick & Easy Compositions
107107

@@ -120,20 +120,20 @@ wac plug my-namespace:package-name --plug some-namespace:other-package-name -o p
120120

121121
### Encoding Compositions
122122

123-
To encode a composition, use the `wac encode` command:
123+
To perform a composition, use the `wac compose` command:
124124

125125
```
126-
wac encode -t input.wac
126+
wac compose -t input.wac
127127
```
128128

129-
This will encode `input.wac` as a WebAssembly component and write the text
129+
This will use `input.wac` to perform the composition and write the text
130130
representation of the component to stdout.
131131

132132
```
133-
wac encode -o output.wasm input.wac
133+
wac compose -o output.wasm input.wac
134134
```
135135

136-
This will encode `input.wac` as a WebAssembly component named `output.wasm`.
136+
This will perform the composition specified in `input.wac` and output a WebAssembly component named `output.wasm`.
137137

138138
#### Dependencies
139139

@@ -143,7 +143,7 @@ to cause dependencies to be imported in the output component, use the
143143
`--import-dependencies` flag:
144144

145145
```
146-
wac encode --import-dependencies -o output.wasm input.wac
146+
wac compose --import-dependencies -o output.wasm input.wac
147147
```
148148

149149
Dependencies may be located within a `deps` subdirectory, with an expected structure of:
@@ -170,7 +170,7 @@ search for dependencies.
170170
The location of specific dependencies may also be specified with the `--dep` CLI option:
171171
172172
```
173-
wac encode --dep foo:bar=./baz.wasm -o output.wasm input.wac
173+
wac compose --dep foo:bar=./baz.wasm -o output.wasm input.wac
174174
```
175175
176176
By default, dependencies must be binary-encoded WebAssembly components; to

examples/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@ world root {
3434

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

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

39-
`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.
39+
`wac` can be used as a CLI tool. The `wac compose` 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

4343
```bash
44-
wac encode script.wac -o composed.wasm
44+
wac compose script.wac -o composed.wasm
4545
```
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 (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.
47+
*Note*: `wac compose` 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 compose` expects to find those components in the `deps/example` directory.
4848

4949
## `wac plug`
5050

src/bin/wac.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use anyhow::Result;
22
use clap::Parser;
33
use owo_colors::{OwoColorize, Stream, Style};
4-
use wac_cli::commands::{EncodeCommand, ParseCommand, PlugCommand, ResolveCommand};
4+
use wac_cli::commands::{ComposeCommand, ParseCommand, PlugCommand, ResolveCommand};
55

66
fn version() -> &'static str {
77
option_env!("CARGO_VERSION_INFO").unwrap_or(env!("CARGO_PKG_VERSION"))
@@ -17,10 +17,10 @@ fn version() -> &'static str {
1717
)]
1818
#[command(version = version())]
1919
enum Wac {
20+
Plug(PlugCommand),
21+
Compose(ComposeCommand),
2022
Parse(ParseCommand),
2123
Resolve(ResolveCommand),
22-
Encode(EncodeCommand),
23-
Plug(PlugCommand),
2424
}
2525

2626
#[tokio::main]
@@ -30,7 +30,7 @@ async fn main() -> Result<()> {
3030
if let Err(e) = match Wac::parse() {
3131
Wac::Parse(cmd) => cmd.exec().await,
3232
Wac::Resolve(cmd) => cmd.exec().await,
33-
Wac::Encode(cmd) => cmd.exec().await,
33+
Wac::Compose(cmd) => cmd.exec().await,
3434
Wac::Plug(cmd) => cmd.exec().await,
3535
} {
3636
eprintln!(

src/commands.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
//! Module for CLI commands.
22
3-
mod encode;
3+
mod compose;
44
mod parse;
55
mod plug;
66
mod resolve;
77

8-
pub use self::encode::*;
8+
pub use self::compose::*;
99
pub use self::parse::*;
1010
pub use self::plug::*;
1111
pub use self::resolve::*;
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ where
2525
))
2626
}
2727

28-
/// Encodes a WAC source file into a WebAssembly component.
28+
/// Compose WebAssembly components using the provided WAC source file.
2929
#[derive(Args)]
3030
#[clap(disable_version_flag = true)]
31-
pub struct EncodeCommand {
31+
pub struct ComposeCommand {
3232
/// The directory to search for package dependencies.
3333
#[clap(long, value_name = "PATH", default_value = "deps")]
3434
pub deps_dir: PathBuf,
@@ -37,7 +37,7 @@ pub struct EncodeCommand {
3737
#[clap(long = "dep", short, value_name = "PKG=PATH", value_parser = parse::<String, PathBuf>)]
3838
pub deps: Vec<(String, PathBuf)>,
3939

40-
/// Whether to skip validation of the encoded WebAssembly component.
40+
/// Whether to skip validation of the composed WebAssembly component.
4141
#[clap(long)]
4242
pub no_validate: bool,
4343

@@ -69,10 +69,10 @@ pub struct EncodeCommand {
6969
pub path: PathBuf,
7070
}
7171

72-
impl EncodeCommand {
72+
impl ComposeCommand {
7373
/// Executes the command.
7474
pub async fn exec(self) -> Result<()> {
75-
log::debug!("executing encode command");
75+
log::debug!("executing compose command");
7676

7777
let contents = fs::read_to_string(&self.path)
7878
.with_context(|| format!("failed to read file `{path}`", path = self.path.display()))?;

0 commit comments

Comments
 (0)