This commit is contained in:
parent
6fd8d5e45e
commit
1a95046b87
3 changed files with 30 additions and 14 deletions
|
@ -11,3 +11,4 @@ log = "0.4.19"
|
|||
regex = "1.9.1"
|
||||
manifest = { path = "../manifest" }
|
||||
clap = { version = "4.3.12", features = ["derive"] }
|
||||
colored = "2.0.4"
|
||||
|
|
|
@ -3,7 +3,7 @@ use clap::{Parser, Subcommand};
|
|||
use log::error;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[clap(name = "pkgr", version = "0.1.0", author = "")]
|
||||
#[clap(name = "pkgr", version)]
|
||||
pub struct Cli {
|
||||
#[command(subcommand)]
|
||||
pub command: Command,
|
||||
|
@ -19,6 +19,9 @@ pub enum Command {
|
|||
},
|
||||
/// Remove a package from the system
|
||||
Remove {
|
||||
/// Remove the package from index too
|
||||
#[arg(short, long, default_value_t = false)]
|
||||
index: bool,
|
||||
package_identifier: PackageIdentifier,
|
||||
},
|
||||
/// List packages
|
||||
|
@ -46,8 +49,12 @@ impl Command {
|
|||
error!("Install is not yet implemented.");
|
||||
}
|
||||
}
|
||||
Command::Remove { package_identifier: _ } => {
|
||||
error!("Remove is not yet implemented.");
|
||||
Command::Remove { package_identifier: _, index } => {
|
||||
if *index {
|
||||
error!("Index removal is not yet implemented.");
|
||||
} else {
|
||||
error!("Remove is not yet implemented.");
|
||||
}
|
||||
}
|
||||
Command::List { installed: _ } => {
|
||||
error!("List is not yet implemented.");
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
use clap::Parser;
|
||||
|
||||
|
||||
|
||||
|
||||
use crate::commands::{Cli};
|
||||
use log::{info, SetLoggerError};
|
||||
use colored::Colorize;
|
||||
use crate::commands::Cli;
|
||||
use log::{debug, info, SetLoggerError, trace};
|
||||
use std::env;
|
||||
|
||||
mod commands;
|
||||
mod package;
|
||||
|
@ -12,8 +10,16 @@ mod package;
|
|||
fn main() {
|
||||
setup_logger().expect("Unable to setup logger.");
|
||||
|
||||
trace!("Parsing command line arguments...");
|
||||
let c = Cli::parse();
|
||||
info!("Command: {:?}", c);
|
||||
debug!("Command line arguments parsed.");
|
||||
|
||||
trace!("Executing command...");
|
||||
c.command.execute();
|
||||
debug!("Command executed.");
|
||||
|
||||
trace!("Exiting...");
|
||||
info!("Done.");
|
||||
}
|
||||
|
||||
fn setup_logger() -> Result<(), SetLoggerError> {
|
||||
|
@ -22,13 +28,15 @@ fn setup_logger() -> Result<(), SetLoggerError> {
|
|||
out.finish(format_args!(
|
||||
"{} {}",
|
||||
match record.level().to_string().chars().nth(0).unwrap_or('I') {
|
||||
'E' | 'W' => "!!",
|
||||
_ => "**",
|
||||
'T' => "##".cyan(),
|
||||
'D' => "::".yellow(),
|
||||
'E' | 'W' => "!!".red(),
|
||||
_ => "**".blue(),
|
||||
},
|
||||
message
|
||||
message.to_string().bright_white()
|
||||
))
|
||||
})
|
||||
.level(log::LevelFilter::Info)
|
||||
.level(env::var("PKGR_LOG_LEVEL").unwrap_or_else(|_| "info".to_string()).parse().unwrap_or(log::LevelFilter::Info))
|
||||
.chain(std::io::stdout())
|
||||
.apply()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue