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)]
|
|
|
|
#[clap(name = "pkgr", version = "0.1.0", author = "")]
|
|
|
|
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 {
|
|
|
|
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,
|
|
|
|
package_identifier,
|
|
|
|
} => {
|
|
|
|
if *build {
|
|
|
|
error!("Build is not yet implemented.");
|
|
|
|
} else {
|
|
|
|
error!("Install is not yet implemented.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Command::Remove { package_identifier } => {
|
|
|
|
error!("Remove is not yet implemented.");
|
|
|
|
}
|
|
|
|
Command::List { installed } => {
|
|
|
|
error!("List is not yet implemented.");
|
|
|
|
}
|
|
|
|
Command::Update => {
|
|
|
|
error!("Update is not yet implemented.");
|
|
|
|
}
|
|
|
|
Command::None => {
|
|
|
|
error!("No command was specified.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|