Skip to main content

ncu/
cli.rs

1use clap::Parser;
2use std::path::PathBuf;
3
4/// Check for outdated npm dependencies
5#[derive(Parser, Debug, Clone)]
6#[command(name = "ncu")]
7#[command(author, version, about, long_about = None)]
8pub struct Args {
9    /// Check globally installed packages (npm)
10    #[arg(short, long)]
11    pub global: bool,
12
13    /// Path to project directory (defaults to current directory)
14    #[arg(value_name = "PATH", conflicts_with = "global")]
15    pub path: Option<PathBuf>,
16
17    /// Update package.json (patch updates only by default)
18    #[arg(short, long)]
19    pub update: bool,
20
21    /// Include minor updates (use with -u as -um)
22    #[arg(short, long)]
23    pub minor: bool,
24
25    /// Force update all to absolute latest (use with -u as -uf)
26    #[arg(short, long)]
27    pub force: bool,
28
29    /// Include pre-release versions
30    #[arg(short, long)]
31    pub pre_release: bool,
32}
33
34impl Args {
35    pub fn project_path(&self) -> PathBuf {
36        self.path.clone().unwrap_or_else(|| PathBuf::from("."))
37    }
38}