nu_plugin_sys/nu/
mod.rs

1use crate::sys::{sysinfo, Sys};
2use nu_errors::ShellError;
3use nu_plugin::Plugin;
4use nu_protocol::{CallInfo, ReturnSuccess, ReturnValue, Signature, Value};
5
6use futures::executor::block_on;
7
8impl Plugin for Sys {
9    fn config(&mut self) -> Result<Signature, ShellError> {
10        Ok(Signature::build("sys")
11            .desc("View information about the current system.")
12            .filter())
13    }
14
15    fn begin_filter(&mut self, callinfo: CallInfo) -> Result<Vec<ReturnValue>, ShellError> {
16        Ok(block_on(sysinfo(callinfo.name_tag))
17            .into_iter()
18            .map(ReturnSuccess::value)
19            .collect())
20    }
21
22    fn filter(&mut self, _: Value) -> Result<Vec<ReturnValue>, ShellError> {
23        Ok(vec![])
24    }
25}