pub mod error;
pub mod execute;
pub mod manager;
pub mod method;
pub mod schemes;
use crate::method::Methodical;
use clap::{Parser, Subcommand, ValueEnum};
pub use error::{BleurError as Error, Result, beautiful_exit};
use method::{Method, git::Git, http::Http};
use std::path::PathBuf;
use url::Url;
pub static TEMPLATE: &str = include_str!("./template/template.toml");
pub static COLLECTION: &str = include_str!("./template/collection.toml");
#[derive(ValueEnum, Copy, Clone, Debug, PartialEq, Eq)]
pub enum Protocol {
Git,
Http,
}
impl std::fmt::Display for Protocol {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Git => write!(f, "git"),
Self::Http => write!(f, "http"),
}
}
}
impl Methodical for Protocol {
fn to_method(&self, url: Url, path: PathBuf) -> method::Method {
match self {
Self::Git => Method::Git(Git::new(url, path)),
Self::Http => Method::Http(Http::new(url, path)),
}
}
}
#[derive(Debug, Parser)]
#[command(name = "bleur", version)]
#[command(
about = "That buddy that will get everything ready for you",
long_about = "A template assistant from Bleur to manage your templates, bootstrap your project quickly!"
)]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
}
#[derive(Debug, Subcommand)]
pub enum Commands {
New {
#[arg(value_name = "WHERE")]
path: Option<PathBuf>,
#[arg(short, long)]
#[clap(default_value = "https://git.oss.uzinfocom.uz/bleur/templates.git")]
template: String,
#[arg(short, long)]
#[clap(default_value_t = Protocol::Git)]
method: Protocol,
},
Init,
}