2020-06-01 21:46:53 -04:00
|
|
|
// gt - a gitea cli client
|
|
|
|
|
// Written by Wyatt J. Miller
|
|
|
|
|
// All right reserved, 2020
|
2020-06-13 15:01:49 -04:00
|
|
|
// Licensed by the MPL v2
|
2020-06-01 21:46:53 -04:00
|
|
|
|
2020-06-13 15:01:49 -04:00
|
|
|
mod arg;
|
|
|
|
|
mod config;
|
|
|
|
|
mod issue;
|
|
|
|
|
mod repo;
|
2021-07-27 01:48:05 -04:00
|
|
|
mod request;
|
2020-06-13 15:01:49 -04:00
|
|
|
|
2021-07-27 01:48:05 -04:00
|
|
|
use clap::ArgMatches;
|
2020-06-01 21:46:53 -04:00
|
|
|
|
|
|
|
|
fn main() {
|
2021-07-27 01:48:05 -04:00
|
|
|
let mut matches: ArgMatches = arg::get_args();
|
|
|
|
|
let mut config = crate::config::Configuration::new();
|
|
|
|
|
|
|
|
|
|
let auth = request::Authentication::new(&config);
|
|
|
|
|
let request = auth.request_chooser(config.clone(), matches);
|
2020-06-01 21:46:53 -04:00
|
|
|
|
2021-07-27 01:48:05 -04:00
|
|
|
match request.arg_value.subcommand() {
|
2020-06-13 15:01:49 -04:00
|
|
|
("", None) => println!("No subcommand was given!"),
|
2020-06-01 21:46:53 -04:00
|
|
|
("repo", Some(repo_matches)) => {
|
2020-06-13 15:01:49 -04:00
|
|
|
let repo = repo::Repository::new();
|
|
|
|
|
|
|
|
|
|
// TODO: match expression should be here
|
2020-06-01 21:46:53 -04:00
|
|
|
if repo_matches.is_present("create") {
|
2021-07-27 01:48:05 -04:00
|
|
|
repo.create_repo(&request);
|
2020-06-01 21:46:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if repo_matches.is_present("delete") {
|
2020-06-13 15:01:49 -04:00
|
|
|
repo.delete_repo(&config, repo_matches);
|
2020-06-01 21:46:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if repo_matches.is_present("fork") {
|
2020-06-13 15:01:49 -04:00
|
|
|
repo.fork_repo(&config, repo_matches)
|
2020-06-01 21:46:53 -04:00
|
|
|
}
|
2020-06-13 15:01:49 -04:00
|
|
|
|
|
|
|
|
if repo_matches.is_present("search") {
|
|
|
|
|
repo.search_repo(&config, repo_matches)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if repo_matches.is_present("list") {
|
|
|
|
|
repo.list_repo(&config)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
("issue", Some(issue_matches)) => {
|
|
|
|
|
let issue = issue::Issue::new();
|
|
|
|
|
|
|
|
|
|
// TODO: match expression should be here
|
|
|
|
|
if issue_matches.is_present("create") {
|
|
|
|
|
issue.create_issue(&config, issue_matches);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
_ => println!("Huh?")
|
2020-06-01 21:46:53 -04:00
|
|
|
}
|
2021-07-27 01:48:05 -04:00
|
|
|
}
|
|
|
|
|
|