Skip to main content

lux_cli/project/
debug.rs

1use clap::Args;
2use eyre::Result;
3use lux_lib::workspace::Workspace;
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 workspace = Workspace::current()?;
19
20    if let Some(workspace) = workspace {
21        for project in workspace.members() {
22            let toml = project.toml();
23
24            println!("Project name: {}", toml.package());
25            println!("Project version: {}", toml.version()?);
26
27            println!("Project location: {}", project.root().display());
28
29            if args.list_files {
30                let project_files = project.project_files();
31                if project_files.is_empty() {
32                    println!("\nNo included project files detected.");
33                } else {
34                    let project_tree = term_tree_from_paths(&project_files);
35                    println!("\nIncluded project files:\n\n{project_tree}.");
36                }
37            }
38        }
39    } else {
40        eprintln!("Could not find project in current directory.");
41    }
42
43    Ok(())
44}