Skip to content

Commit

Permalink
feat(cli): added ctl args
Browse files Browse the repository at this point in the history
  • Loading branch information
lemosep committed Apr 30, 2024
1 parent d840539 commit f0f4519
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 6 deletions.
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
40 changes: 36 additions & 4 deletions cli/src/ctl/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,40 @@
use clap::Subcommand;
use std::net::SocketAddr;

use clap::{Args, Subcommand};

#[derive(Debug, Subcommand)]
pub enum Cmd {
Node,
Service,
Deploy,
#[command(arg_required_else_help = true)]
Node(NodeArgs),
#[command(arg_required_else_help = true)]
Service(ServiceArgs),
#[command(arg_required_else_help = true)]
Deploy(DeployArgs),
}

#[derive(Args, Debug)]
#[group(required = true, multiple = false)]
pub struct NodeArgs {
#[arg(short, long)]
list: bool,
#[arg(short, long)]
show: SocketAddr,
}

#[derive(Args, Debug)]
#[group(required = true, multiple = false)]
pub struct ServiceArgs {
#[arg(short, long)]
list: bool,
#[arg(short, long)]
show: String,
}

#[derive(Args, Debug)]
#[group(required = true, multiple = false)]
pub struct DeployArgs {
#[arg(short, long)]
list: bool,
#[arg(short, long)]
show: String,
}
4 changes: 3 additions & 1 deletion cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mod ctl;
mod worker;

#[derive(Debug, Parser)]
struct Cli {
pub struct Cli {
#[command(subcommand)]
cmd: Cmd,
}
Expand All @@ -17,11 +17,13 @@ enum Cmd {

#[derive(Args, Debug)]
struct Ctl {
#[command(subcommand)]
cmd: ctl::Cmd,
}

#[derive(Args, Debug)]
struct Worker {
#[command(subcommand)]
cmd: worker::Cmd,
}

Expand Down

0 comments on commit f0f4519

Please sign in to comment.