82 lines
2.1 KiB
Rust
82 lines
2.1 KiB
Rust
// gt - a gitea cli client
|
|
// Written by Wyatt J. Miller
|
|
// All right reserved, 2020 - 2021
|
|
// Licensed by the MPL v2
|
|
|
|
mod arg;
|
|
mod config;
|
|
mod generate;
|
|
mod issue;
|
|
mod pr;
|
|
mod repo;
|
|
mod request;
|
|
mod user;
|
|
mod util;
|
|
|
|
use clap::ArgMatches;
|
|
|
|
fn main() {
|
|
let matches: ArgMatches = arg::get_args();
|
|
let mut config = crate::config::Configuration::new();
|
|
config.load_envs();
|
|
|
|
if config.base_url.is_empty()
|
|
|| config.api_token.is_none()
|
|
|| (config.username.is_none() && config.password.is_none())
|
|
{
|
|
config.load_config_file();
|
|
}
|
|
|
|
let auth = request::Authentication::new(&config);
|
|
let request = auth.request_chooser(config.clone(), matches);
|
|
|
|
match request.arg_value.subcommand() {
|
|
("", None) => println!("No subcommand was given!"),
|
|
("repo", Some(repo_matches)) => {
|
|
let repo = repo::Repository::new();
|
|
|
|
// TODO: match expression should be here
|
|
if repo_matches.is_present("create") {
|
|
repo.create_repo(&request);
|
|
}
|
|
|
|
if repo_matches.is_present("delete") {
|
|
repo.delete_repo(&request);
|
|
}
|
|
|
|
if repo_matches.is_present("fork") {
|
|
repo.fork_repo(&request)
|
|
}
|
|
|
|
if repo_matches.is_present("search") {
|
|
repo.search_repo(&request)
|
|
}
|
|
|
|
if repo_matches.is_present("list") {
|
|
repo.list_repo(&request)
|
|
}
|
|
|
|
if repo_matches.is_present("push") {
|
|
repo.push_to_remote(&request, &config)
|
|
}
|
|
|
|
if repo_matches.is_present("pull") {
|
|
repo.pull_from_remote(&request, &config)
|
|
}
|
|
|
|
if repo_matches.is_present("clone") {
|
|
repo.clone_from_remote(&request, &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(&request);
|
|
}
|
|
}
|
|
_ => println!("Huh?"),
|
|
}
|
|
}
|