|
@ -1,5 +1,6 @@ |
|
|
use crate::builtins::{Builtin, BuiltinConfig};
|
|
|
use crate::builtins::{Builtin, BuiltinConfig};
|
|
|
use crate::error::ShellError;
|
|
|
use crate::error::ShellError;
|
|
|
|
|
|
use rand::Rng;
|
|
|
use webbrowser;
|
|
|
use webbrowser;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -7,7 +8,16 @@ pub struct Rick; |
|
|
|
|
|
|
|
|
impl Builtin for Rick {
|
|
|
impl Builtin for Rick {
|
|
|
fn execute(&mut self, _: &mut BuiltinConfig, _: Vec<String>) -> Result<(), ShellError> {
|
|
|
fn execute(&mut self, _: &mut BuiltinConfig, _: Vec<String>) -> Result<(), ShellError> {
|
|
|
webbrowser::open("https://www.youtube.com/watch?v=dQw4w9WgXcQ").expect("cant open website",);
|
|
|
|
|
|
|
|
|
const RICK_ROLLS: &[&str] = &[
|
|
|
|
|
|
("https://www.youtube.com/watch?v=dQw4w9WgXcQ"),
|
|
|
|
|
|
("https://www.youtube.com/watch?v=MO7bRMa9bmA&t"),
|
|
|
|
|
|
("https://www.youtube.com/watch?v=cvh0nX08nRw"),
|
|
|
|
|
|
("https://www.youtube.com/watch?v=JVzVat71LKg"),
|
|
|
|
|
|
("https://www.youtube.com/watch?v=hvL1339luv0")
|
|
|
|
|
|
];
|
|
|
|
|
|
let mut rng = rand::thread_rng();
|
|
|
|
|
|
let rick = RICK_ROLLS[rng.gen_range(0..RICK_ROLLS.len())];
|
|
|
|
|
|
webbrowser::open(rick).expect("cant open website",);
|
|
|
Ok(())
|
|
|
Ok(())
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|