2020-06-01 21:46:53 -04:00
|
|
|
// gt - a gitea cli client
|
|
|
|
|
// Written by Wyatt J. Miller
|
2021-07-28 21:30:24 -04:00
|
|
|
// All right reserved, 2020 - 2021
|
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;
|
2021-12-18 20:11:18 -05:00
|
|
|
mod pr;
|
|
|
|
|
mod user;
|
|
|
|
|
mod util;
|
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-28 21:30:24 -04:00
|
|
|
let matches: ArgMatches = arg::get_args();
|
|
|
|
|
let config = crate::config::Configuration::new();
|
2021-07-27 01:48:05 -04:00
|
|
|
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") {
|
2021-12-18 15:07:46 -05:00
|
|
|
repo.delete_repo(&request);
|
2020-06-01 21:46:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if repo_matches.is_present("fork") {
|
2021-12-18 15:07:46 -05:00
|
|
|
repo.fork_repo(&request)
|
2020-06-01 21:46:53 -04:00
|
|
|
}
|
2020-06-13 15:01:49 -04:00
|
|
|
|
|
|
|
|
if repo_matches.is_present("search") {
|
2021-12-18 15:07:46 -05:00
|
|
|
repo.search_repo(&request)
|
2020-06-13 15:01:49 -04:00
|
|
|
}
|
2021-12-18 15:07:46 -05:00
|
|
|
|
2020-06-13 15:01:49 -04:00
|
|
|
if repo_matches.is_present("list") {
|
2021-12-18 15:07:46 -05:00
|
|
|
repo.list_repo(&request)
|
2020-06-13 15:01:49 -04:00
|
|
|
}
|
2021-12-19 20:01:05 -05:00
|
|
|
|
|
|
|
|
if repo_matches.is_present("push") {
|
|
|
|
|
repo.push_to_remote(&request)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if repo_matches.is_present("pull") {
|
|
|
|
|
repo.pull_from_remote(&request)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if repo_matches.is_present("clone") {
|
|
|
|
|
repo.clone_from_remote(&request, &config)
|
|
|
|
|
}
|
2021-12-18 15:07:46 -05:00
|
|
|
}
|
2020-06-13 15:01:49 -04:00
|
|
|
("issue", Some(issue_matches)) => {
|
|
|
|
|
let issue = issue::Issue::new();
|
|
|
|
|
|
|
|
|
|
// TODO: match expression should be here
|
|
|
|
|
if issue_matches.is_present("create") {
|
2021-12-18 20:11:18 -05:00
|
|
|
issue.create_issue(&request);
|
2020-06-13 15:01:49 -04:00
|
|
|
}
|
2021-12-18 15:07:46 -05:00
|
|
|
}
|
|
|
|
|
_ => println!("Huh?"),
|
2020-06-01 21:46:53 -04:00
|
|
|
}
|
2021-07-27 01:48:05 -04:00
|
|
|
}
|