easy_install/
lib.rs

1mod artifact;
2mod download;
3mod env;
4mod install;
5mod manfiest;
6mod tool;
7mod ty;
8
9use clap::Parser;
10use tool::add_output_to_path;
11use anyhow::Result;
12
13#[derive(Parser, Debug, Clone)]
14#[command(version, about, long_about = None)]
15pub struct Args {
16    #[arg()]
17    pub url: String,
18
19    #[arg(short, long)]
20    dir: Option<String>,
21
22    #[arg(long, default_value_t = false)]
23    install_only: bool,
24
25    #[arg(long, value_delimiter = ',')]
26    bin: Vec<String>,
27}
28
29pub async fn run_main(args: Args) -> Result<()> {
30    let Args {
31        url,
32        dir,
33        install_only,
34        bin,
35    } = args;
36    let output = install::install(&url, &bin, dir).await?;
37    if !install_only {
38        add_output_to_path(&output);
39    }
40    if output.is_empty() {
41        println!("No file installed from {url}");
42    }
43    Ok(())
44}