mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 13:25:00 +00:00
55 lines
1.2 KiB
Rust
55 lines
1.2 KiB
Rust
use std::path::PathBuf;
|
|
use std::process::ExitCode;
|
|
|
|
use clap::{Args, Parser, Subcommand};
|
|
use colored::Colorize;
|
|
|
|
use crate::commands::ExitStatus;
|
|
|
|
mod commands;
|
|
mod logging;
|
|
|
|
#[derive(Parser)]
|
|
#[command(author, version, about)]
|
|
#[command(propagate_version = true)]
|
|
struct Cli {
|
|
#[command(subcommand)]
|
|
command: Commands,
|
|
}
|
|
|
|
#[derive(Subcommand)]
|
|
enum Commands {
|
|
/// Install dependencies from a `requirements.text` file.
|
|
Install(InstallArgs),
|
|
}
|
|
|
|
#[derive(Args)]
|
|
struct InstallArgs {
|
|
/// Path to the `requirements.text` file to install.
|
|
src: PathBuf,
|
|
}
|
|
|
|
#[async_std::main]
|
|
async fn main() -> ExitCode {
|
|
let cli = Cli::parse();
|
|
|
|
let _ = logging::setup_logging();
|
|
|
|
let result = match &cli.command {
|
|
Commands::Install(install) => commands::install(&install.src).await,
|
|
};
|
|
|
|
match result {
|
|
Ok(code) => code.into(),
|
|
Err(err) => {
|
|
#[allow(clippy::print_stderr)]
|
|
{
|
|
eprintln!("{}", "puffin failed".red().bold());
|
|
for cause in err.chain() {
|
|
eprintln!(" {} {cause}", "Cause:".bold());
|
|
}
|
|
}
|
|
ExitStatus::Error.into()
|
|
}
|
|
}
|
|
}
|