1pub mod error;
2pub mod execute;
3pub mod manager;
4pub mod method;
5pub mod schemes;
6
7use crate::method::Methodical;
8use clap::{Parser, Subcommand, ValueEnum};
9pub use error::{BleurError as Error, Result, beautiful_exit};
10use method::{Method, git::Git, http::Http};
11use std::path::PathBuf;
12use url::Url;
13
14pub static TEMPLATE: &str = include_str!("./template/template.toml");
15pub static COLLECTION: &str = include_str!("./template/collection.toml");
16
17#[derive(ValueEnum, Copy, Clone, Debug, PartialEq, Eq)]
18pub enum Protocol {
19 Git,
20 Http,
21}
22
23impl std::fmt::Display for Protocol {
24 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
25 match self {
26 Self::Git => write!(f, "git"),
27 Self::Http => write!(f, "http"),
28 }
29 }
30}
31
32impl Methodical for Protocol {
33 fn to_method(&self, url: Url, path: PathBuf) -> method::Method {
34 match self {
35 Self::Git => Method::Git(Git::new(url, path)),
36 Self::Http => Method::Http(Http::new(url, path)),
37 }
38 }
39}
40
41#[derive(Debug, Parser)]
43#[command(name = "bleur", version)]
44#[command(
45 about = "That buddy that will get everything ready for you",
46 long_about = "A template assistant from Bleur to manage your templates, bootstrap your project quickly!"
47)]
48pub struct Cli {
49 #[command(subcommand)]
50 pub command: Commands,
51}
52
53#[derive(Debug, Subcommand)]
54pub enum Commands {
55 New {
57 #[arg(value_name = "WHERE")]
60 path: Option<PathBuf>,
61
62 #[arg(short, long)]
65 #[clap(default_value = "https://git.oss.uzinfocom.uz/bleur/templates.git")]
66 template: String,
67
68 #[arg(short, long)]
70 #[clap(default_value_t = Protocol::Git)]
71 method: Protocol,
72 },
73
74 Init,
76}