Skip to content

Commit

Permalink
feat(cli-wrapper): added Node CLI wrapper with initial commands and c…
Browse files Browse the repository at this point in the history
…onfig parsing

	•	Implemented wrapper with commands to start coordinator and nodes.
	•	Added default node configuration file and logic to create node home directory if missing.
	•	Introduced child process handling with temporary resolution for termination issues.
	•	Defined node configuration struct with methods for reading and parsing config data.
	•	Updated README.md with usage instructions.
  • Loading branch information
kevinjaypatel committed Nov 9, 2024
1 parent 43782e3 commit 2b18893
Show file tree
Hide file tree
Showing 7 changed files with 370 additions and 6 deletions.
33 changes: 27 additions & 6 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ members = [
"./crates/context/config",
"./crates/meroctl",
"./crates/merod",
"./crates/merow",
"./crates/network",
"./crates/node",
"./crates/node-primitives",
Expand Down
19 changes: 19 additions & 0 deletions crates/merow/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "merow"
version = "0.1.0"
authors.workspace = true
edition.workspace = true
repository.workspace = true
license.workspace = true

[dependencies]
clap = { workspace = true, features = ["env", "derive"] }
const_format.workspace = true
eyre.workspace = true

tokio = { workspace = true, features = ["full"] }
toml = "0.5.2"
serde = { workspace = true, features = ["derive"] }

[lints]
workspace = true
90 changes: 90 additions & 0 deletions crates/merow/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Core Cli Wrapper (crate::merow)

A CLI wrapper for the Calimero Node that provides a default node configuration file for initializing a node, and quickly running a development environment for testing P2P Calimero Apps.

## Features

- Custom Node Configuration File
- Simple Commands to Initialize and Run a Calimero Node
- Creates a Node Home Directory (if it doesn't already exist)

## Prerequisites
- Rust: [Official Rust Installation](https://www.rust-lang.org/tools/install)

## Setting up
Clone the project

```bash
git clone https://github.com/kevinjaypatel/core.git
```

Change to repo

```bash
cd core
```

Check out cli-wrapper
```bash
git branch cli-wrapper
```

## Usage

Setup the Default Configuration: `./crates/merow/config/default.toml`

```javascript
[coordinator]
name = "coordinator"
server_port = 2427
swarm_port = 2527
home = "data"

[admin]
name = "node1"
server_port = 2428
swarm_port = 2528
home = "data"
```

Initialize a coordinator
`$ merow -- init-coordinator`

Initialize a node
`$ merow -- init-node`

Start a running coordinator
`$ merow -- start-coordinator`

Start a running node
`$ merow -- start-node`


## How to Run (from project root)

### Build the Rust Package
```bash
cargo build
```

### Starting up a Coordinator (same steps apply for Node Configuration)
E.g. Initializes Coordinator (with defaults)
```bash
cargo run -p merow -- init-coordinator
```

Start a running coordinator
```bash
cargo run -p merow -- start-coordinator
```

### Accessing the coordinator via Admin Dashboard
```bash
http://localhost:<coordinator.server_port>/admin-dashboard/
```

## Roadmap

- Additional commands for `Dev Context` creation and `Peer Invitation`
- Add a boolean flag to the Configuration File for Deploying the Admin Dashboard
- Multi-node deployment (e.g. node1, node2, ... nodeN)
11 changes: 11 additions & 0 deletions crates/merow/config/default.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[coordinator]
name = "coordinator"
server_port = 2427
swarm_port = 2527
home = "data"

[admin]
name = "node1"
server_port = 2428
swarm_port = 2528
home = "data"
Loading

0 comments on commit 2b18893

Please sign in to comment.