Move fortune() to core lib
This commit is contained in:
parent
46311a3ede
commit
dd7c2fd7ab
4 changed files with 19 additions and 19 deletions
|
|
@ -42,6 +42,7 @@ lazy_static = "1.5.0"
|
||||||
libc = "0.2.158"
|
libc = "0.2.158"
|
||||||
once_cell = "1.20.2"
|
once_cell = "1.20.2"
|
||||||
pretty_assertions = "1.4.0"
|
pretty_assertions = "1.4.0"
|
||||||
|
rand = "0.9.0"
|
||||||
ratatui = { version = "0.29.0", features = ["serde", "macros"] }
|
ratatui = { version = "0.29.0", features = ["serde", "macros"] }
|
||||||
raw-cpuid = "11.2.0"
|
raw-cpuid = "11.2.0"
|
||||||
regex = "1.11.1"
|
regex = "1.11.1"
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
// along with Deja-vu. If not, see <https://www.gnu.org/licenses/>.
|
// along with Deja-vu. If not, see <https://www.gnu.org/licenses/>.
|
||||||
//
|
//
|
||||||
use color_eyre::Result;
|
use color_eyre::Result;
|
||||||
|
use rand::random;
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
prelude::*,
|
prelude::*,
|
||||||
widgets::{Block, Borders, Clear, Paragraph, Wrap},
|
widgets::{Block, Borders, Clear, Paragraph, Wrap},
|
||||||
|
|
@ -95,3 +96,19 @@ impl Component for Popup {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn fortune() -> String {
|
||||||
|
String::from(match random::<u8>() / 4 {
|
||||||
|
0 => "FUN FACT\n\n\nComputers barely work.",
|
||||||
|
1 => "CRASH OVERRIDE\n\n\n\"Hack the planet!\"",
|
||||||
|
2 => "CATS\n\n\n\"All your base are belong to us!\"",
|
||||||
|
3 => "HMM\n\n\nThis has all happened before...\n\nThis will all happen again.",
|
||||||
|
4 => "CYPHER\n\n\n\"I don’t even see the code. All I see is blonde, brunette, red-head.\"",
|
||||||
|
5 => "CONGRATULATIONS\n\n\nYour did it!",
|
||||||
|
6 => "DID YOU KNOW?\n\n\nmacOS includes a built-in screen reader!",
|
||||||
|
7 => "TIP OF THE DAY\n\n\nNever go full Snappy!",
|
||||||
|
8 => "WORDS OF WISDOM\n\n\n\nIt’s not DNS,\n\nThere’s no way it’s DNS,\n\nIt was DNS.",
|
||||||
|
9 => "HAL 9000\n\n\n\"I'm sorry Dave, I'm afraid I can't do that.\"",
|
||||||
|
_ => "COMPLETE\n\n\nThank you for using this tool!",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,6 @@ tokio-util = "0.7.11"
|
||||||
tracing = "0.1.41"
|
tracing = "0.1.41"
|
||||||
tracing-error = "0.2.0"
|
tracing-error = "0.2.0"
|
||||||
tracing-subscriber = { version = "0.3.18", features = ["env-filter", "serde"] }
|
tracing-subscriber = { version = "0.3.18", features = ["env-filter", "serde"] }
|
||||||
rand = "0.8.5"
|
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
anyhow = "1.0.86"
|
anyhow = "1.0.86"
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use color_eyre::Result;
|
use color_eyre::Result;
|
||||||
use rand::random;
|
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
crossterm::event::KeyEvent,
|
crossterm::event::KeyEvent,
|
||||||
layout::{Constraint, Direction, Layout},
|
layout::{Constraint, Direction, Layout},
|
||||||
|
|
@ -258,7 +257,7 @@ impl App {
|
||||||
}
|
}
|
||||||
Mode::Done => {
|
Mode::Done => {
|
||||||
self.action_tx
|
self.action_tx
|
||||||
.send(Action::DisplayPopup(popup::Type::Success, fortune()))?;
|
.send(Action::DisplayPopup(popup::Type::Success, popup::fortune()))?;
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
@ -739,19 +738,3 @@ fn build_right_items(app: &App, cur_mode: Mode) -> Action {
|
||||||
}
|
}
|
||||||
Action::UpdateRight(labels, start_index, items)
|
Action::UpdateRight(labels, start_index, items)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fortune() -> String {
|
|
||||||
String::from(match random::<u8>() / 4 {
|
|
||||||
0 => "FUN FACT\n\n\nComputers barely work.",
|
|
||||||
1 => "CRASH OVERRIDE\n\n\n\"Hack the planet!\"",
|
|
||||||
2 => "CATS\n\n\n\"All your base are belong to us!\"",
|
|
||||||
3 => "HMM\n\n\nThis has all happened before...\n\nThis will all happen again.",
|
|
||||||
4 => "CYPHER\n\n\n\"I don’t even see the code. All I see is blonde, brunette, red-head.\"",
|
|
||||||
5 => "CONGRATULATIONS\n\n\nYour did it!",
|
|
||||||
6 => "DID YOU KNOW?\n\n\nmacOS includes a built-in screen reader!",
|
|
||||||
7 => "TIP OF THE DAY\n\n\nNever go full Snappy!",
|
|
||||||
8 => "WORDS OF WISDOM\n\n\n\nIt’s not DNS,\n\nThere’s no way it’s DNS,\n\nIt was DNS.",
|
|
||||||
9 => "HAL 9000\n\n\n\"I'm sorry Dave, I'm afraid I can't do that.\"",
|
|
||||||
_ => "COMPLETE\n\n\nThank you for using this tool!",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue