modcli/commands/
framework.rs

1use crate::command::Command;
2use crate::error::ModCliError;
3use crate::modcli_version;
4use crate::output::{build, print, BLUE, GREY, LIGHT_BLUE};
5pub struct FrameworkCommand;
6
7impl Command for FrameworkCommand {
8    /// Command name
9    fn name(&self) -> &'static str {
10        "framework"
11    }
12
13    // Command help
14    fn help(&self) -> Option<&str> {
15        Some("Framework Information")
16    }
17
18    // Command hidden
19    fn hidden(&self) -> bool {
20        true
21    }
22
23    // Command validate
24    fn validate(&self, args: &[String]) -> Result<(), ModCliError> {
25        if !args.is_empty() {
26            Err(ModCliError::InvalidUsage(
27                "framework does not accept any arguments.".into(),
28            ))
29        } else {
30            Ok(())
31        }
32    }
33
34    // Command execute
35    fn execute(&self, _args: &[String]) {
36        // Construct framework information
37        let framework = build()
38            .part("Mod")
39            .color(LIGHT_BLUE)
40            .bold()
41            .part("cli")
42            .color(BLUE)
43            .part(":")
44            .color(GREY)
45            .space()
46            .part("version:")
47            .space()
48            .part(modcli_version())
49            .bold()
50            .get();
51
52        // Construct framework description
53        let description = build()
54            .part("⬢")
55            .color(BLUE)
56            .space()
57            .part("cli framework for")
58            .italic()
59            .space()
60            .part("Rust")
61            .italic()
62            .bold()
63            .color(GREY)
64            .space()
65            .get();
66
67        print::newline();
68        print::line(&framework);
69        print::line(&description);
70        print::newline();
71    }
72}