use std::path::PathBuf;
use std::vec::Vec;
use anyhow::Result;
use clap::{Parser, Subcommand};
pub mod add_assets;
pub mod check_package;
pub mod fetch;
pub mod gh_fetcher;
#[macro_use]
extern crate lazy_static;
use clyde::app::App;
use clyde::ui::Ui;
use add_assets::add_assets_cmd;
use check_package::check_packages;
use fetch::fetch;
#[derive(Debug, Parser)]
#[clap(name = "clydetools", version)]
pub struct Cli {
#[clap(subcommand)]
command: Command,
}
#[derive(Debug, Subcommand)]
enum Command {
#[clap(alias("add-build"))]
AddAssets {
package_file: PathBuf,
version: String,
#[clap(short, long)]
arch_os: Option<String>,
urls: Vec<String>,
},
Check {
#[clap(required = true)]
package_files: Vec<PathBuf>,
},
Fetch {
#[clap(required = true)]
package_files: Vec<PathBuf>,
},
}
fn main() -> Result<()> {
let cli = Cli::parse();
let ui = Ui::default();
let home = App::find_home(&ui)?;
match cli.command {
Command::AddAssets {
package_file,
version,
arch_os,
urls,
} => {
let app = App::new(&home)?;
add_assets_cmd(&app, &ui, &package_file, &version, &arch_os, &urls)
}
Command::Check { package_files } => check_packages(&ui, &package_files),
Command::Fetch { package_files } => {
let app = App::new(&home)?;
fetch(&app, &ui, &package_files)
}
}
}