mod browser;
mod cdp;
mod color;
mod demo;
mod encode;
mod error;
mod font;
mod image;
mod key;
mod recording;
mod render;
mod settings;
mod tape;
mod terminal;
mod theme;
mod timeline;
pub use color::Rgb;
pub use demo::{Demo, Event};
pub use error::{Error, Location, Result};
pub use key::{Key, KeyCode};
pub use recording::{Recording, Saved};
pub use settings::{Length, LoopOffset, Settings, Timing, WindowBar};
pub use tape::{Caption, Command, Focus, Pattern, Scene, ScrollTarget, Step, Tape, WaitScope};
pub use theme::Theme;
pub(crate) fn which(program: &str) -> Option<std::path::PathBuf> {
let mut names = vec![program.to_string()];
if cfg!(windows) {
let extensions = std::env::var("PATHEXT").unwrap_or(".EXE;.CMD;.BAT".into());
names.extend(
extensions
.split(';')
.filter(|extension| !extension.is_empty())
.map(|extension| format!("{program}{extension}")),
);
}
let path = std::path::Path::new(program);
if path.components().count() > 1 {
return names.iter().map(std::path::PathBuf::from).find(|candidate| candidate.is_file());
}
std::env::split_paths(&std::env::var_os("PATH")?)
.find_map(|directory| names.iter().map(|name| directory.join(name)).find(|candidate| candidate.is_file()))
}
#[cfg(test)]
mod tests {
#[test]
fn which_finds_programs_by_name_or_path_and_not_what_is_missing() {
let shell = super::which("sh").expect("sh is on PATH");
assert!(shell.is_file());
assert_eq!(super::which(shell.to_str().unwrap()), Some(shell));
assert_eq!(super::which("definitely-not-a-program-9000"), None);
}
}