diff --git a/src/arg.rs b/src/arg.rs new file mode 100644 index 0000000..dddb2d4 --- /dev/null +++ b/src/arg.rs @@ -0,0 +1,71 @@ +use clap::{App, Arg, SubCommand, ArgMatches}; + +/// Global function that grabs the arguments and shows the user help on any given command. +/// An error occurs when a command passes through and it doesn't match the argument specified. +pub fn get_args() -> ArgMatches<'static> { + let matches = App::new("gt") + .version("0.0.1") + .author("Wyatt J. Miller ") + .about("It's a Gitea CLI client!") + .subcommand(SubCommand::with_name("repo") + .about("Create, delete, list, search, or fork a repository") + .arg(Arg::with_name("create") + .short("c") + .long("create") + .value_names(&["REPO"]) + .help("Create a repository for a user") + ) + .arg(Arg::with_name("search") + .short("s") + .long("search") + .value_name("REPO") + .help("Search repositories for a user") + ) + .arg(Arg::with_name("list") + .short("l") + .long("list") + .help("List all the repositories for the authenticated user") + ) + .arg(Arg::with_name("delete") + .short("d") + .long("delete") + .value_names(&["OWNER", "REPO"]) + .help("Delete a repository for a user") + ) + .arg(Arg::with_name("fork") + .short("f") + .long("fork") + .value_names(&["OWNER", "REPO"]) + .help("Fork a repository for a user") + ) + ) + .subcommand(SubCommand::with_name("issue") + .about("Create, search, comment, close, or reopen an issue") + .arg(Arg::with_name("create") + .short("c") + .long("c") + .value_names(&["OWNER"]) + .help("Create an issue for a repository") + ) + ) + .subcommand(SubCommand::with_name("pr") + .about("Create, search, comment, merge, and close pull requests") + .arg(Arg::with_name("create") + .short("c") + .long("create") + .value_names(&["REPO"]) + .help("Create a new pull request for a repository") + ) + ) + .subcommand(SubCommand::with_name("user") + .about("Check the status, repositories, followers, and other such items about your and others user") + .arg(Arg::with_name("get") + .short("g") + .long("get") + .help("Get your authenticated user") + ) + ) + .get_matches(); + + matches +} \ No newline at end of file