-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Eduardo Lemos <[email protected]> Co-authored-by: Luiz Felipe Gonçalves <[email protected]>
- Loading branch information
1 parent
bb9755f
commit 78409b6
Showing
4 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!(), | ||
} | ||
} |