1use clap::Args;
2use lux_lib::package;
3use lux_lib::{config::Config, operations::Download, rockspec::Rockspec, tree::InstallTree};
4
5use miette::Result;
6
7use crate::workspace::current_workspace_or_user_tree;
8
9#[derive(Args)]
10pub struct Info {
11 package: package::Req,
12}
13
14pub async fn info(data: Info, config: Config) -> Result<()> {
15 let tree = current_workspace_or_user_tree(&config)?;
16
17 let rockspec = Download::new(&data.package, &config)
18 .download_rockspec()
19 .await?
20 .rockspec;
21
22 if tree.match_rocks(&data.package)?.is_found() {
23 println!("Currently installed in {}", tree.root().display());
24 }
25
26 println!("Package name: {}", rockspec.package());
27 println!("Package version: {}", rockspec.version());
28 println!();
29
30 println!(
31 "Summary: {}",
32 rockspec
33 .description()
34 .summary
35 .as_ref()
36 .unwrap_or(&"None".to_string())
37 );
38 println!(
39 "Description: {}",
40 rockspec
41 .description()
42 .detailed
43 .as_ref()
44 .unwrap_or(&"None".to_string())
45 .trim()
46 );
47 println!(
48 "License: {}",
49 rockspec
50 .description()
51 .license
52 .as_ref()
53 .unwrap_or(&"Unknown (all rights reserved by the author)".to_string())
54 );
55 println!(
56 "Maintainer: {}",
57 rockspec
58 .description()
59 .maintainer
60 .as_ref()
61 .unwrap_or(&"Unspecified".to_string())
62 );
63
64 Ok(())
65}