Skip to content

Commit

Permalink
Initializes init command
Browse files Browse the repository at this point in the history
  • Loading branch information
ultimaweapon committed Feb 25, 2024
1 parent d904124 commit 459e480
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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") {
Expand Down

0 comments on commit 459e480

Please sign in to comment.