packager/pkgr/src/commands/mod.rs

71 lines
1.9 KiB
Rust
Raw Normal View History

2023-07-16 19:00:09 +02:00
use crate::package::identifier::PackageIdentifier;
2023-07-17 11:50:19 +02:00
use clap::{Parser, Subcommand};
use log::error;
2023-07-16 19:00:09 +02:00
2023-07-17 11:50:19 +02:00
#[derive(Parser, Debug)]
2023-07-17 12:13:14 +02:00
#[clap(name = "pkgr", version)]
2023-07-17 11:50:19 +02:00
pub struct Cli {
#[command(subcommand)]
pub command: Command,
}
#[derive(Subcommand, Debug)]
2023-07-16 19:00:09 +02:00
pub enum Command {
2023-07-17 11:50:19 +02:00
/// Install a package
Install {
#[arg(short, long, default_value_t = false)]
build: bool,
package_identifier: PackageIdentifier,
},
/// Remove a package from the system
Remove {
2023-07-17 12:13:14 +02:00
/// Remove the package from index too
#[arg(short, long, default_value_t = false)]
index: bool,
2023-07-17 11:50:19 +02:00
package_identifier: PackageIdentifier,
},
/// List packages
List {
/// List installed packages
#[arg(short, long, default_value_t = true)]
installed: bool,
},
/// Update packages on the system
2023-07-16 19:00:09 +02:00
Update,
2023-07-17 11:50:19 +02:00
#[command(hide = true)]
None,
}
impl Command {
pub fn execute(&self) {
match self {
Command::Install {
build,
2023-07-17 11:50:51 +02:00
package_identifier: _,
2023-07-17 11:50:19 +02:00
} => {
if *build {
error!("Build is not yet implemented.");
} else {
error!("Install is not yet implemented.");
}
}
2023-07-17 12:13:14 +02:00
Command::Remove { package_identifier: _, index } => {
if *index {
error!("Index removal is not yet implemented.");
} else {
error!("Remove is not yet implemented.");
}
2023-07-17 11:50:19 +02:00
}
2023-07-17 11:50:51 +02:00
Command::List { installed: _ } => {
2023-07-17 11:50:19 +02:00
error!("List is not yet implemented.");
}
Command::Update => {
error!("Update is not yet implemented.");
}
Command::None => {
error!("No command was specified.");
}
}
}
}