lux_cli/project/
debug.rs

1use clap::Args;
2use eyre::Result;
3use lux_lib::project::Project;
4
5use crate::utils::file_tree::term_tree_from_paths;
6
7#[derive(Args)]
8pub struct DebugProject {
9    /// List files that are included.
10    /// To avoid copying large files that are not relevant to the build process,
11    /// Lux excludes hidden files and files that are ignored
12    /// (e.g. by .gitignore or other .ignore files).
13    #[arg(long)]
14    list_files: bool,
15}
16
17pub fn debug_project(args: DebugProject) -> Result<()> {
18    let project = Project::current()?;
19
20    if let Some(project) = project {
21        let rocks = project.toml();
22
23        println!("Project name: {}", rocks.package());
24        println!("Project version: {}", rocks.version());
25
26        println!("Project location: {}", project.root().display());
27
28        if args.list_files {
29            let project_files = project.project_files();
30            if project_files.is_empty() {
31                println!("\nNo included project files detected.");
32            } else {
33                let project_tree = term_tree_from_paths(&project_files);
34                println!("\nIncluded project files:\n\n{}.", project_tree);
35            }
36        }
37    } else {
38        eprintln!("Could not find project in current directory.");
39    }
40
41    Ok(())
42}