ayun_console/support/
console.rs

1use crate::{support::STYLES, Console};
2use clap::{
3    builder::{IntoResettable, Str, StyledStr},
4    Command,
5};
6use std::collections::{BTreeMap, HashMap};
7
8impl Console {
9    pub fn name(mut self, name: impl Into<Str>) -> Self {
10        self.inner = self.inner.name(name);
11        self
12    }
13
14    pub fn version(mut self, ver: impl IntoResettable<Str>) -> Self {
15        self.inner = self.inner.version(ver);
16        self
17    }
18
19    pub fn about(mut self, about: impl IntoResettable<StyledStr>) -> Self {
20        self.inner = self.inner.about(about);
21        self
22    }
23}
24
25const LOGO: &str = r"
26░░      ░░░  ░░░░  ░░  ░░░░  ░░   ░░░  ░
27▒  ▒▒▒▒  ▒▒▒  ▒▒  ▒▒▒  ▒▒▒▒  ▒▒    ▒▒  ▒
28▓  ▓▓▓▓  ▓▓▓▓    ▓▓▓▓  ▓▓▓▓  ▓▓  ▓  ▓  ▓
29█        █████  █████  ████  ██  ██    █
30█  ████  █████  ██████      ███  ███   █
31";
32
33impl Default for Console {
34    fn default() -> Self {
35        let command = Command::default()
36            .styles(STYLES)
37            .name("ayun")
38            .version(env!("CARGO_PKG_VERSION"))
39            .about(format!("\n {} \n {}", LOGO, env!("CARGO_PKG_DESCRIPTION")));
40
41        Self {
42            inner: command,
43            commands: BTreeMap::new(),
44            closures: HashMap::new(),
45        }
46    }
47}