feat: rename test -> sample, add logo

This commit is contained in:
2020-11-22 22:44:55 +08:00
parent 3504bd9a6d
commit 79df9405a1
4 changed files with 33 additions and 11 deletions

16
cargotool.logo.txt Normal file
View File

@@ -0,0 +1,16 @@
{color1} {color2} ,----, {colore}
{color1} {color2} ,/ .`| {colore}
{color1} ,----.. {color2} ,` .' : ,--, {colore}
{color1} / / \ {color2} ; ; / ,--.'| {colore}
{color1}| : : __ ,-. ,---. {color2} .'___,/ ,' ,---. ,---. | | : {colore}
{color1}. | ;. / ,' ,'/ /| ,----._,. ' ,'\ {color2} | : | ' ,'\ ' ,'\ : : ' {colore}
{color1}. ; /--` ,--.--. ' | |' | / / ' / / / |{color2} ; |.'; ; / / | / / || ' | {colore}
{color1}; | ; / \ | | ,'| : |. ; ,. :{color2} `----' | |. ; ,. :. ; ,. :' | | {colore}
{color1}| : | .--. .-. |' : / | | .\ .' | |: :{color2} ' : ;' | |: :' | |: :| | : {colore}
{color1}. | '___ \__\/: . .| | ' . ; '; |' | .; :{color2} | | '' | .; :' | .; :' : |__ {colore}
{color1}' ; : .'| ," .--.; |; : | ' . . || : |{color2} ' : || : || : || | '.'|{colore}
{color1}' | '/ :/ / ,. || , ; `---`-'| | \ \ / {color2} ; |.' \ \ / \ \ / ; : ;{colore}
{color1}| : /; : .' \---' .'__/\_: | `----' {color2} '---' `----' `----' | , / {colore}
{color1} \ \ .' | , .-./ | : : {color2} ---`-' {colore}
{color1} `---` `--`---' \ \ / {color2} {colore}
{color1} `--`-' {color2} {colore}

View File

@@ -1,4 +1,4 @@
use clap::{App, Arg, ArgMatches};
use clap::{App, ArgMatches};
use crate::cmd::CommandError;
pub struct CommandImpl;
@@ -6,14 +6,20 @@ pub struct CommandImpl;
impl CommandImpl {
pub fn process_command<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
app.arg(Arg::with_name("verbose").long("verbose").short("v").multiple(true).help("Show verbose info"))
// app.arg(Arg::with_name("verbose").long("verbose").short("v").multiple(true).help("Show verbose info"))
app
}
pub fn run(arg_matches: &ArgMatches) -> CommandError {
let verbose_count = arg_matches.occurrences_of("verbose");
information!("Verbose count: {}", verbose_count);
information!("This is default command cli ...");
// TODO ...
pub fn run(_arg_matches: &ArgMatches) -> CommandError {
let logo = include_str!("../cargotool.logo.txt");
println!("{}", logo
.replace("{color1}", "\x1B[1m\x1B[91m")
.replace("{colore}", "\x1B[0m")
.replace("{color2}", "\x1B[32m")
);
information!("{} v{}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"));
information!("Please use `{} --help` to see help message", env!("CARGO_PKG_NAME"));
println!();
Ok(())
}
}

View File

@@ -5,10 +5,10 @@ pub struct CommandImpl;
impl Command for CommandImpl {
fn name(&self) -> &str { "test" }
fn name(&self) -> &str { "sample" }
fn subcommand<'a>(&self) -> App<'a, 'a> {
SubCommand::with_name(self.name()).about("Test subcommand")
SubCommand::with_name(self.name()).about("Sample subcommand")
}
fn run(&self, _arg_matches: &ArgMatches, _sub_arg_matches: &ArgMatches) -> CommandError {

View File

@@ -3,14 +3,14 @@
mod cmd;
mod cmd_default;
mod cmd_crate;
mod cmd_test;
mod cmd_sample;
use clap::App;
use cmd::{Command, CommandError};
fn main() -> CommandError {
let commands: Vec<Box<dyn Command>> = vec![
Box::new(cmd_test::CommandImpl),
Box::new(cmd_sample::CommandImpl),
Box::new(cmd_crate::CommandImpl),
];
let mut app = App::new(env!("CARGO_PKG_NAME"))