[][src]Function cmdtree::completion::create_tree_completion_items

pub fn create_tree_completion_items<'a, R>(
    cmdr: &Commander<'a, R>
) -> Vec<CompletionInfo<'a>>

Constructs a set of space delimited items that could be completed at the current path.

Examples


let mut cmder = Builder::default_config("eg")
	.begin_class("one", "") // a class
		.begin_class("two", "")
		.add_action("three", "", |_, _| ())
		.end_class()
	.end_class()
	.begin_class("hello", "").end_class()
	.into_commander().unwrap();

let v: Vec<_> = create_tree_completion_items(&cmder).into_iter().map(|x| x.completestr).collect();
assert_eq!(v, vec!["hello", "one", "one two", "one two three"]
	.into_iter().map(|x| x.to_string()).collect::<Vec<_>>());

cmder.parse_line("one", true, &mut std::io::sink());

let v: Vec<_> = create_tree_completion_items(&cmder).into_iter().map(|x| x.completestr).collect();
assert_eq!(v, vec!["two", "two three"]
	.into_iter().map(|x| x.to_string()).collect::<Vec<_>>());