feat(args): add --no-docs flag for tui

This commit is contained in:
Orhun Parmaksız 2022-01-27 00:09:36 +03:00
parent fed7612caf
commit e8c052e730
No known key found for this signature in database
GPG key ID: F83424824B3E4B90
2 changed files with 7 additions and 1 deletions

View file

@ -18,6 +18,8 @@ pub struct Args {
pub tick_rate: u64,
/// Path of the Linux kernel documentation.
pub kernel_docs: Option<PathBuf>,
/// Do not parse/show Linux kernel documentation.
pub no_docs: bool,
}
impl Args {
@ -36,6 +38,7 @@ impl Args {
"set the path of the kernel documentation",
"<path>",
);
opts.optflag("n", "no-docs", "do not show the kernel documentation");
opts.optflag("h", "help", "display this help and exit");
opts.optflag("V", "version", "output version information and exit");
opts
@ -67,6 +70,7 @@ impl Args {
.ok()?
.unwrap_or(250),
kernel_docs: matches.opt_str("D").map(PathBuf::from),
no_docs: matches.opt_present("n"),
})
}
}

View file

@ -45,7 +45,9 @@ pub fn run<Output: Write>(args: Args, output: Output) -> Result<()> {
terminal.clear()?;
let event_handler = EventHandler::new(args.tick_rate);
let mut sysctl = Sysctl::init(Config::default())?;
sysctl.update_docs_from_cache(args.kernel_docs.as_ref(), &Cache::init()?)?;
if !args.no_docs {
sysctl.update_docs_from_cache(args.kernel_docs.as_ref(), &Cache::init()?)?;
}
let mut app = App::new(&mut sysctl);
while app.running {
terminal.draw(|frame| ui::render(frame, &mut app))?;