diff --git a/src/main.rs b/src/main.rs index 8c5275f..0a467ae 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,14 +1,26 @@ -use clap::Command; -use std::process::ExitCode; +use clap::{value_parser, Arg, ArgMatches, Command}; +use std::{path::PathBuf, process::ExitCode}; fn main() -> ExitCode { // Parse arguments. - let args = Command::new("warp").get_matches(); + let args = Command::new("warp") + .subcommand( + Command::new("init") + .about("Setup an existing directory to be resuming on another computer") + .arg(Arg::new("name").help( + "Unique name of this directory on the server (default to directory name)", + ).long("name").value_name("NAME")) + .arg( + Arg::new("server") + .help("URL of the server to use (default to https://api.warpgate.sh)").long("server").value_name("URL"), + ).arg(Arg::new("directory").help("The directory to setup (default to current directory)").value_name("DIRECTORY").value_parser(value_parser!(PathBuf))), + ) + .get_matches(); // Execute the command. let res = match args.subcommand() { - Some(_) => todo!(), - None => wrap(), + Some(("init", args)) => init(args), + _ => wrap(), }; match res { @@ -17,6 +29,10 @@ fn main() -> ExitCode { } } +fn init(_: &ArgMatches) -> Result<(), ExitCode> { + todo!() +} + fn wrap() -> Result<(), ExitCode> { // Get current shell. let shell = match std::env::var_os("SHELL") {