mod cat;
mod cd;
mod find;
mod grep;
mod head;
mod ls;
mod pwd;
mod wc;
pub use cat::cat;
pub use cd::{cd, cd_up};
pub use find::find_tree;
pub use grep::grep;
pub use head::head;
pub use ls::ls;
pub use pwd::pwd;
pub use wc::wc;
use crate::document::{DocumentTree, NodeId};
pub(super) fn collect_subtree(node: NodeId, tree: &DocumentTree) -> Vec<NodeId> {
let mut result = vec![node];
let mut stack = vec![node];
while let Some(current) = stack.pop() {
for child in tree.children_iter(current) {
result.push(child);
stack.push(child);
}
}
result
}