cargo_graphmod/
app_builder.rs

1/**
2 * Copyright 2023 Thomas Hügel.
3 * This file is part of Cargo Graphmod.
4 * SPDX-License-Identifier: GPL-3.0-only
5 */
6use std::path::Path;
7
8use crate::{
9    dependencies_graph::DependenciesGraph,
10    dependencies_processor::rust_processor::target_computer::RustDependencyProcessor,
11    files_reader,
12    formatter::{dot_formatter::DotFormatter, Formatter},
13    parser::rust_parser::RustParser,
14};
15
16pub fn run_app(directory: &str, pkg_name: &str) -> String {
17    let path = Path::new(directory);
18    let skip_length = path.iter().count();
19    let mut trie = DependenciesGraph::new();
20    files_reader::build_dependencies_trie::<RustParser>(path, &mut trie, skip_length).expect(
21        "Unable to read ./src; please consider changing to the root directory of your package.",
22    );
23    DotFormatter::show::<RustDependencyProcessor>(&trie, pkg_name)
24}