Skip to content

Commit

Permalink
Merge pull request #10 from MyceliaNetwork/dani_clap_cli
Browse files Browse the repository at this point in the history
CLI
  • Loading branch information
danielterwiel committed Sep 26, 2023
2 parents b5e41e9 + cdb2be5 commit ecbf672
Show file tree
Hide file tree
Showing 18 changed files with 733 additions and 53 deletions.
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Expand Up @@ -10,7 +10,8 @@
"vadimcn.vscode-lldb",
"rust-lang.rust-analyzer",
"bytecodealliance.wit-idl",
"tamasfe.even-better-toml"
"tamasfe.even-better-toml",
"zxh404.vscode-proto3"
],
"settings": {
"editor.formatOnSave": true,
Expand Down
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Expand Up @@ -7,7 +7,8 @@
"vadimcn.vscode-lldb",
"rust-lang.rust-analyzer",
"bytecodealliance.wit-idl",
"tamasfe.even-better-toml"
"tamasfe.even-better-toml",
"zxh404.vscode-proto3"
],
"unwantedRecommendations": []
}
72 changes: 53 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
@@ -1,8 +1,8 @@
[workspace]

members = [
# Tooling
"xtask",
"protos",
"cli",
"development_server",
"wasmtime_components",
Expand Down
45 changes: 42 additions & 3 deletions README.md
Expand Up @@ -5,20 +5,59 @@ Open Source Application Stack & PaaS
## Installation

```sh
cargo xtask build
cargo run build
```

NOTE: We opted for [cargo-xtask](https://github.com/matklad/cargo-xtask) because Cargo build.rs is [not supported for workspaces](https://github.com/rust-lang/cargo/issues/8732#issuecomment-950252765)
**IMPORTANT**: `cargo build` will fail because we have to use [cargo-xtask](https://github.com/matklad/cargo-xtask/) to build the ./components/ folder before building the project. Reason: Cargo's build.rs is [not supported for workspaces](https://github.com/rust-lang/cargo/issues/8732#issuecomment-950252765)

## CLI

### Info

```sh
cargo run
```

### Start Development Server

```sh
cargo run start
```

### Stop Development Server

```sh
cargo run stop
```

### Deploy

```sh
cargo run deploy --component="your_component_name"
```

## Development Server

```sh
RUST_LOG=info cargo run --package development_server
```

### Logging
## Logging

We use [env_logger](https://docs.rs/env_logger/0.10.0/env_logger/) for logging. Please see their documentation for more information on setting custom log levels, filtering, and more.

Default CLI log level is `info`.

Basic example usage:

```sh
RUST_LOG=error cargo run start
RUST_LOG=warn cargo run start
RUST_LOG=debug cargo run start
RUST_LOG=info cargo run start # default
RUST_LOG=trace cargo run start
```

## Community & Contributing & Help

Come join our [Discord](https://discord.gg/hKMtmdMJ)
Expand Down
12 changes: 11 additions & 1 deletion cli/Cargo.toml
Expand Up @@ -2,9 +2,19 @@
name = "cli"
version = "0.1.0"
edition = "2021"
default-run = "cli"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap-cargo = "0.11.0"
clap = { version = "4.4.2", features = ["derive"] }
env_logger = { workspace = true }
log = { workspace = true }
open = "5.0.0"
prost = "0.12.0"
thiserror = "1.0.48"
tokio = { version = "1.32.0", features = ["full"] }
tonic = { version = "0.10.0" }

[build-dependencies]
tonic-build = "0.10.0"
13 changes: 13 additions & 0 deletions cli/build.rs
@@ -0,0 +1,13 @@
use std::{env, path::PathBuf};

fn main() -> Result<(), Box<dyn std::error::Error>> {
// See https://github.com/hyperium/tonic/blob/master/examples/build.rs
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
tonic_build::configure()
.file_descriptor_set_path(out_dir.join("development_descriptor.bin"))
.compile(&["../protos/proto/development.proto"], &["../protos/proto"])
.unwrap();

tonic_build::compile_protos("../protos/proto/development.proto")?;
Ok(())
}

0 comments on commit ecbf672

Please sign in to comment.