use std::{ffi::OsStr, process::Command};
use anyhow::Result;
use shrs::{prelude::*, readline::line::LineContents};
pub fn open_manpage(mut contents: StateMut<LineContents>, sh: &Shell) -> Result<()> {
_open_manpage(&mut contents, "man");
Ok(())
}
pub fn open_manpage_with<S: AsRef<OsStr>>(state: &mut LineContents, man_command: S) {
_open_manpage(state, man_command)
}
fn _open_manpage<S: AsRef<OsStr>>(line: &mut LineContents, man_command: S) {
let full_command = line.get_full_command();
let Some(command) = full_command.split(' ').next() else {
return;
};
Command::new(man_command).arg(command).spawn().unwrap();
line.cb.clear();
}