diff --git a/side-node/src/cli/mod.rs b/side-node/src/cli/mod.rs new file mode 100644 index 0000000..831839a --- /dev/null +++ b/side-node/src/cli/mod.rs @@ -0,0 +1,38 @@ +use clap::{arg, Parser, Subcommand}; + +pub(crate) fn parse_args() -> Args { + let args = Args::parse(); + + match &args.command { + Some(Commands::Init { init }) => { + if *init { + println!("Initializing Side Node") + } + } + Some(Commands::Run {}) => { + println!("Running side node") + } + None => todo!(), + } + + args +} + +/// Simple program to greet a person +#[derive(Parser)] +#[command(version, about, long_about = None)] +pub(crate) struct Args { + #[command(subcommand)] + command: Option, +} + +#[derive(Subcommand)] +enum Commands { + /// runs the Side Node + Run {}, + Init { + /// initializes a Side Node with a config file and keypair + #[arg(short, long)] + init: bool, + }, +} diff --git a/side-node/src/main.rs b/side-node/src/main.rs index eec8aec..dc1ff8a 100644 --- a/side-node/src/main.rs +++ b/side-node/src/main.rs @@ -1,7 +1,11 @@ +use cli::parse_args; use websockets::{WebSocket, WebSocketError}; +pub(crate) mod cli; + #[tokio::main] async fn main() -> Result<(), WebSocketError> { + parse_args(); let mut ws = WebSocket::connect("ws://localhost:8080/").await?; ws.send_text("foo".to_string()).await?;