Skip to content

Commit

Permalink
feat(cli): initial structure (#40)
Browse files Browse the repository at this point in the history
Co-authored-by: Eduardo Lemos <eduardolemosep@gmail.com>
Co-authored-by: Luiz Felipe Gonçalves <git@luizfelipe.dev>
  • Loading branch information
3 people authored May 31, 2024
1 parent bb9755f commit 78409b6
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 1 deletion.
7 changes: 7 additions & 0 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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["crates/*", "ctl", "proto", "worker"]
members = ["cli", "crates/*", "ctl", "proto", "worker"]
resolver = "2"

[workspace.package]
Expand Down
10 changes: 10 additions & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "cli"
version.workspace = true
edition.workspace = true

[lints]
workspace = true

[dependencies]
clap.workspace = true
66 changes: 66 additions & 0 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
use std::net::SocketAddr;

use clap::{Parser, Subcommand};

#[derive(Debug, Parser)]
pub struct Cli {
#[command(subcommand)]
cmd: Cmd,
}

#[derive(Debug, Subcommand)]
pub enum Cmd {
#[clap(subcommand)]
Node(NodeCmd),
#[clap(subcommand)]
Service(ServiceCmd),
}

#[derive(Debug, Subcommand)]
pub enum NodeCmd {
List,
Show {
address: SocketAddr,
},
#[clap(subcommand)]
Worker(WorkerCmd),
}

#[derive(Debug, Subcommand)]
pub enum WorkerCmd {
Remove { address: SocketAddr },
}

#[derive(Debug, Subcommand)]
pub enum ServiceCmd {
List,
Show { id: String },
Deploy { id: String, image: String },
Terminate { id: String },
}

fn main() {
let cli = Cli::parse();

match cli.cmd {
Cmd::Node(cmd) => handle_node(&cmd),
Cmd::Service(cmd) => handle_service(&cmd),
}
}

fn handle_node(cmd: &NodeCmd) {
match cmd {
NodeCmd::List => todo!(),
NodeCmd::Show { .. } => todo!(),
NodeCmd::Worker(_) => todo!(),
}
}

fn handle_service(cmd: &ServiceCmd) {
match cmd {
ServiceCmd::List => todo!(),
ServiceCmd::Show { .. } => todo!(),
ServiceCmd::Deploy { .. } => todo!(),
ServiceCmd::Terminate { .. } => todo!(),
}
}

0 comments on commit 78409b6

Please sign in to comment.