summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs103
1 files changed, 81 insertions, 22 deletions
diff --git a/src/main.rs b/src/main.rs
index c2725ee..447c93a 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,4 +1,4 @@
-use clap::{Parser, Subcommand};
+use clap::{CommandFactory, Parser, Subcommand};
use std::sync::Arc;
use colored::Colorize;
use std::path::{Path, PathBuf};
@@ -22,7 +22,12 @@ mod apply;
mod resolver;
#[derive(Parser)]
-#[command(name = "ror", about = "Ror package manager")]
+#[command(
+ name = "ror",
+ about = "ror package manager",
+ version = concat!(env!("CARGO_PKG_VERSION"), " MPL 2"),
+ disable_help_subcommand = true
+)]
struct Cli {
#[command(subcommand)]
command: Commands,
@@ -30,86 +35,127 @@ struct Cli {
#[derive(Subcommand)]
enum Commands {
-
+ /// install one or more packages or groups
#[command(alias = "i")]
Install {
+ /// package names or @group specifications to install
#[arg(required = true)]
packages: Vec<String>,
},
-
+
+ /// list available package groups
#[command(alias = "lg")]
ListGroups,
-
+
+ /// synchronize repository package recipes from remote
#[command(alias = "s")]
Sync,
-
+
+ /// remove an installed package
#[command(alias = "d")]
Delete {
+ /// name of the package to remove
package: String,
},
-
+
+ /// list all installed packages
#[command(alias = "l")]
ListInstalled,
+ /// print the total count of installed packages
#[command(alias = "c")]
Count,
-
+
+ /// display detailed information about a package
Info {
+ /// name of the package
package: String,
},
-
+
+ /// update a specific package to the latest available version
Update {
+ /// name of the package to update
package: String,
+ /// check for update without making modifications
#[arg(long)]
dry_run: bool,
},
-
+
+ /// upgrade all installed packages to their latest versions
#[command(alias = "u")]
Upgrade,
-
+
+ /// search for packages by query in repositories
Search {
+ /// search query string
query: String,
},
-
+
+ /// add a new package repository
RepoAdd {
+ /// repository name
name: String,
+ /// repository recipe git url
url: String,
+ /// optional binary package mirror url
mirror: Option<String>,
},
-
+
+ /// remove a configured package repository
RepoRemove {
+ /// name of the repository to remove
name: String,
},
-
+
+ /// list all configured package repositories
RepoList,
-
+
+ /// build a rootfs environment from a package group
BuildRootfs {
+ /// package group name to build
#[arg(long)]
group: String,
+ /// target directory path for rootfs
#[arg(long)]
target: PathBuf,
+ /// target architecture (default: native)
#[arg(long, default_value = "native")]
arch: String,
},
-
+
+ /// atomically replace one package with another
Di {
+ /// package to delete
delete: String,
+ /// package to install
install: String,
},
-
+
+ /// apply declarative system configuration state
#[command(alias = "a")]
Apply {
+ /// show changes without applying them
#[arg(long)]
dry_run: bool,
+ /// custom system.yaml configuration file path
#[arg(long)]
config: Option<PathBuf>,
},
-
+
+ /// check integrity of installed packages
Check,
-
+
+ /// generate default configuration file at /etc/ror/ror.conf
GenConfig,
-
+
+ /// display ror version information
Version,
+
+ /// print this message or the help of the given subcommand
+ Help {
+ /// name of the subcommand
+ subcommand: Option<String>,
+ },
}
#[tokio::main]
@@ -117,8 +163,22 @@ async fn main() {
let cli = Cli::parse();
match cli.command {
+ Commands::Help { subcommand } => {
+ let mut cmd = Cli::command();
+ if let Some(sub) = subcommand {
+ if let Some(subcmd) = cmd.find_subcommand_mut(&sub) {
+ let _ = subcmd.print_help();
+ } else {
+ let _ = cmd.print_help();
+ }
+ } else {
+ let _ = cmd.print_help();
+ }
+ println!();
+ }
+
Commands::Version => {
- println!("ror {}", env!("CARGO_PKG_VERSION"));
+ println!("ror {} MPL 2", env!("CARGO_PKG_VERSION"));
}
Commands::GenConfig => {
@@ -202,7 +262,6 @@ async fn main() {
&target,
&cfg,
arch,
- true,
) {
eprintln!("{} {}", "[ror]".red().bold(), e);
}