pub fn apply<'g>(&self, pkg_graph: &'g PackageGraph) -> Result<PackageQuery<'g>> {
        if !self.roots.is_empty() {
            // NOTE: The root set packages are specified by name. The tool currently
            // does not handle multiple version of the same package as the current use
            // cases are passing workspace members as the root set, which won't be
            // duplicated.
            let root_set = self.roots.iter().map(|s| s.as_str()).collect();
            Ok(pkg_graph.query_directed(names_to_ids(pkg_graph, root_set), self.direction)?)
        } else {
            ensure!(
                self.direction == DependencyDirection::Forward,
                eyre!("--query-reverse requires roots to be specified")
            );
            Ok(pkg_graph.query_workspace())
        }
    }
Constructs a `PackageQuery` based on these options.
cargo-guppy/src/core.rs