mirror of
https://git.2ki.xyz/spiders/kijetesantakaluotokieni.git
synced 2024-11-10 04:00:26 +01:00
added classic cowsay options, as well as soweli
This commit is contained in:
parent
b41efb3ee2
commit
37b3d1fb11
2 changed files with 125 additions and 44 deletions
|
@ -23,17 +23,20 @@ pub struct CritterConfig {
|
|||
pub up_line: String,
|
||||
pub left_line: String,
|
||||
|
||||
pub object: String,
|
||||
|
||||
pub template: CritterTemplate,
|
||||
}
|
||||
|
||||
impl CritterConfig {
|
||||
pub fn config_from_string(
|
||||
eyes: Option<String>,
|
||||
tongue: Option<String>,
|
||||
line: Option<String>,
|
||||
name: Option<String>,
|
||||
eyes: &Option<String>,
|
||||
tongue: &Option<String>,
|
||||
line: &Option<String>,
|
||||
object: &Option<String>,
|
||||
name: &Option<String>,
|
||||
) -> CritterConfig {
|
||||
let kijetesantakalu: CritterTemplate = CritterTemplate {
|
||||
let kijetesantakalu = CritterTemplate {
|
||||
anchor: 14,
|
||||
critter: r"
|
||||
$6
|
||||
|
@ -41,24 +44,32 @@ impl CritterConfig {
|
|||
/ $1$2\ $5
|
||||
| |$3$4
|
||||
| |
|
||||
(III|\||"
|
||||
(III|\|| $0"
|
||||
.to_string(),
|
||||
};
|
||||
|
||||
let kijetesantakalu_little: CritterTemplate = CritterTemplate {
|
||||
let kijetesantakalu_little = CritterTemplate {
|
||||
anchor: 13,
|
||||
critter: r"
|
||||
$6
|
||||
/__ $6
|
||||
/ $1$2\ $5
|
||||
| |$3$4
|
||||
(I|\||"
|
||||
(I|\|| $0"
|
||||
.to_string(),
|
||||
};
|
||||
let soweli = CritterTemplate {
|
||||
anchor: 10,
|
||||
critter: r"
|
||||
$6
|
||||
___ $6
|
||||
$1$2) $5
|
||||
|||| $0"
|
||||
.to_string(),
|
||||
};
|
||||
|
||||
let default_config: CritterConfig = CritterConfig {
|
||||
left_eye: String::from("."),
|
||||
right_eye: String::from("."),
|
||||
left_eye: String::from("o"),
|
||||
right_eye: String::from("o"),
|
||||
|
||||
left_tongue: String::from(" "),
|
||||
right_tongue: String::from(" "),
|
||||
|
@ -67,6 +78,8 @@ impl CritterConfig {
|
|||
up_line: String::from("|"),
|
||||
left_line: String::from("\\"),
|
||||
|
||||
object: String::from(" "),
|
||||
|
||||
template: kijetesantakalu,
|
||||
};
|
||||
|
||||
|
@ -100,7 +113,13 @@ impl CritterConfig {
|
|||
if let Some(line) = line {
|
||||
match count::count_graphemes(&line) {
|
||||
0 => (),
|
||||
1 => config.right_line = chop::grapheme_at(&line, 0),
|
||||
1 => {
|
||||
(config.right_line, config.up_line, config.left_line) = (
|
||||
chop::grapheme_at(&line, 0),
|
||||
chop::grapheme_at(&line, 0),
|
||||
chop::grapheme_at(&line, 0),
|
||||
)
|
||||
}
|
||||
2 => {
|
||||
(config.right_line, config.up_line) =
|
||||
(chop::grapheme_at(&line, 0), chop::grapheme_at(&line, 1))
|
||||
|
@ -114,11 +133,17 @@ impl CritterConfig {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(object) = object {
|
||||
match count::count_graphemes(&object) {
|
||||
0 => (),
|
||||
_ => config.object = object.clone(),
|
||||
}
|
||||
}
|
||||
if let Some(name) = name {
|
||||
match name.as_str() {
|
||||
"kijetesantakalu" => (),
|
||||
"lili" => config.template = kijetesantakalu_little,
|
||||
"soweli" => config.template = soweli,
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
@ -136,6 +161,7 @@ impl CritterConfig {
|
|||
.replace("$4", &self.right_tongue)
|
||||
.replace("$5", &self.right_line)
|
||||
.replace("$6", &self.up_line)
|
||||
.replace("$7", &self.left_line);
|
||||
.replace("$7", &self.left_line)
|
||||
.replace("$0", &self.object);
|
||||
}
|
||||
}
|
||||
|
|
115
src/main.rs
115
src/main.rs
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
TO DO
|
||||
- options
|
||||
- kijefiles
|
||||
- color
|
||||
- other aminals
|
||||
*/
|
||||
|
||||
|
@ -12,35 +12,6 @@ use clap::Parser;
|
|||
use std::io;
|
||||
use std::io::Read;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[clap(author, version, about, long_about = None)]
|
||||
struct Args {
|
||||
#[clap(short, long)]
|
||||
lukin: Option<String>,
|
||||
|
||||
#[clap(short, long)]
|
||||
uta: Option<String>,
|
||||
|
||||
#[clap(short, long)]
|
||||
palisa: Option<String>,
|
||||
|
||||
#[clap(short, long)]
|
||||
nimi: Option<String>,
|
||||
|
||||
text: Vec<String>,
|
||||
}
|
||||
|
||||
impl Args {
|
||||
fn config_from_arguments(&self) -> critters::CritterConfig {
|
||||
critters::CritterConfig::config_from_string(
|
||||
self.lukin.clone(),
|
||||
self.uta.clone(),
|
||||
self.palisa.clone(),
|
||||
self.nimi.clone(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let cli = Args::parse();
|
||||
let mut text = String::new();
|
||||
|
@ -56,6 +27,90 @@ fn main() {
|
|||
output(&text, config)
|
||||
}
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[clap(author, version, about, long_about = None)]
|
||||
struct Args {
|
||||
#[clap(short = 'e', long)]
|
||||
lukin: Option<String>,
|
||||
|
||||
#[clap(short = 'T', long)]
|
||||
uta: Option<String>,
|
||||
|
||||
#[clap(short = 'o', long)]
|
||||
ijo: Option<String>,
|
||||
|
||||
#[clap(long)]
|
||||
palisa: Option<String>,
|
||||
|
||||
#[clap(short = 'f', long)]
|
||||
nimi: Option<String>,
|
||||
|
||||
#[clap(short = 'W', long)]
|
||||
pakala: Option<String>,
|
||||
|
||||
// implementation of classic cowsay flags
|
||||
#[clap(short = 'b', long)]
|
||||
ilo: bool,
|
||||
|
||||
#[clap(short = 'd', long)]
|
||||
moli: bool,
|
||||
|
||||
#[clap(short = 'g', long)]
|
||||
wile_mani: bool,
|
||||
|
||||
#[clap(short = 'p', long)]
|
||||
monsuta: bool,
|
||||
|
||||
#[clap(short = 's', long)]
|
||||
kasi_nasa: bool,
|
||||
|
||||
#[clap(short = 't', long)]
|
||||
lape: bool,
|
||||
|
||||
#[clap(short = 'w', long)]
|
||||
wawa: bool,
|
||||
|
||||
#[clap(short = 'y', long)]
|
||||
lili: bool,
|
||||
|
||||
#[clap(long)]
|
||||
pilin: bool,
|
||||
|
||||
// optional text input
|
||||
text: Vec<String>,
|
||||
}
|
||||
|
||||
impl Args {
|
||||
fn config_from_arguments(&self) -> critters::CritterConfig {
|
||||
let mut eyes = self.lukin.clone();
|
||||
let mut tongue = self.uta.clone();
|
||||
let mut line = self.palisa.clone();
|
||||
let mut object = self.ijo.clone();
|
||||
let mut name = self.nimi.clone();
|
||||
|
||||
if self.ilo {
|
||||
eyes = Some("==".to_string());
|
||||
} else if self.moli {
|
||||
eyes = Some("xx".to_string());
|
||||
tongue = Some("U".to_string());
|
||||
} else if self.wile_mani {
|
||||
eyes = Some("$$".to_string());
|
||||
} else if self.monsuta {
|
||||
eyes = Some("@@".to_string());
|
||||
} else if self.kasi_nasa {
|
||||
eyes = Some("**".to_string());
|
||||
tongue = Some("U".to_string());
|
||||
} else if self.lape {
|
||||
eyes = Some("--".to_string());
|
||||
} else if self.wawa {
|
||||
eyes = Some("OO".to_string());
|
||||
} else if self.lili {
|
||||
eyes = Some("..".to_string());
|
||||
}
|
||||
critters::CritterConfig::config_from_string(&eyes, &tongue, &line, &object, &name)
|
||||
}
|
||||
}
|
||||
|
||||
fn output(text: &str, config: critters::CritterConfig) -> () {
|
||||
print!(
|
||||
"{}",
|
||||
|
|
Loading…
Reference in a new issue