Skip to content

Commit fae0df7

Browse files
authored
[Feat] print egg when finished generate (#31)
1 parent 7d63f94 commit fae0df7

File tree

4 files changed

+122
-1
lines changed

4 files changed

+122
-1
lines changed

Cargo.lock

Lines changed: 94 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ ansi_term = "0.12.1"
1414
anyhow = "1.0.91"
1515
clap = { version = "4.5.21", features = ["derive"] }
1616
codesnap = { path = "../core", version = "0.7.4" }
17+
ferris-says = "0.3.2"
1718
home = "0.5.9"
1819
indicatif = "0.17.9"
20+
rand = "0.8.5"
1921
serde_json = "1.0.132"

cli/src/egg.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
use rand::{thread_rng, Rng};
2+
use std::io::{stdout, BufWriter};
3+
4+
const WORDS: [&'static str; 8] = [
5+
"Share the code snapshot with your friends!",
6+
"Today is a great day to share CodeSnap!",
7+
"CodeSnap is the best way to share code snippets!",
8+
"The CodeSnap is different from that one in VSCode extension market!",
9+
"Rustaceans are the best!",
10+
"Do you enjoy CodeSnap? Let's star it on GitHub!",
11+
"Enjoy CodeSnap? also try Silicon!",
12+
"Enjoy CodeSnap? also try Freeze!",
13+
];
14+
15+
pub fn say() {
16+
let random_num = thread_rng().gen_range(0..8);
17+
let random_words = WORDS[random_num];
18+
let writer = BufWriter::new(stdout());
19+
let _ = ferris_says::say(random_words, random_words.len(), writer);
20+
}

cli/src/main.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
mod code;
22
mod config;
3+
mod egg;
34
mod logger;
45
mod watermark;
56
mod window;
@@ -12,6 +13,7 @@ use clap::Parser;
1213
use code::create_code;
1314
use codesnap::config::CodeSnap;
1415
use codesnap::config::SnapshotConfig;
16+
use egg::say;
1517
use watermark::create_watermark;
1618
use window::create_window;
1719

@@ -277,5 +279,8 @@ fn with_spinner<T>(cb: impl Fn() -> T) -> T {
277279
fn main() {
278280
if let Err(err) = generate_snapshot() {
279281
logger::error(&err.to_string());
280-
}
282+
return;
283+
};
284+
285+
say();
281286
}

0 commit comments

Comments
 (0)