sh_builtin_common_util/common.rs
1/// Common properties for Rust functions exported as shell builtins.
2pub trait ShellFunctionInfo {
3 /// Rust documentation comments of the fn.
4 fn doc_comments(&self) -> &Vec<String>;
5
6 /// Shell function name.
7 fn name(&self) -> String;
8
9 /// Shell function usage help-text.
10 fn usage(&self) -> String {
11 self.doc_comments()
12 .iter()
13 .take_while(|&c| !c.is_empty())
14 .map(|c| c.clone())
15 .collect::<Vec<String>>()
16 .join(" ")
17 }
18}