diff --git a/linux-mac-install.sh b/linux-mac-install.sh new file mode 100755 index 0000000..69c77af --- /dev/null +++ b/linux-mac-install.sh @@ -0,0 +1,11 @@ +#!/bin/bash +BINARY="pm" + +if [ -f "./$BINARY" ]; then + echo "Installing $BINARY to /usr/local/bin..." + sudo cp "./$BINARY" /usr/local/bin/ + sudo chmod +x /usr/local/bin/$BINARY + echo "Done! You can now use 'pm' from any terminal." +else + echo "Error: Binary '$BINARY' not found. Make sure you are in the folder with the downloaded file." +fi diff --git a/linux-mac-uninstall.sh b/linux-mac-uninstall.sh new file mode 100755 index 0000000..1a1e34d --- /dev/null +++ b/linux-mac-uninstall.sh @@ -0,0 +1,5 @@ +#!/bin/bash +echo "Removing pm binary and encrypted data..." +sudo rm -f /usr/local/bin/pm +rm -rf ~/.my_pass_manager +echo "Uninstalled successfully." diff --git a/pm-linux-mac.tar.gz b/pm-linux-mac.tar.gz index 3a74765..a470642 100644 Binary files a/pm-linux-mac.tar.gz and b/pm-linux-mac.tar.gz differ diff --git a/pm-windows.zip b/pm-windows.zip index 8debe45..f488cc1 100644 Binary files a/pm-windows.zip and b/pm-windows.zip differ diff --git a/release.sh b/release.sh new file mode 100755 index 0000000..2ad2863 --- /dev/null +++ b/release.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -e + +echo "Starting build process..." + +echo "Cleaning up old builds..." +rm -f pm-linux-mac.tar.gz pm-windows.zip + +cargo build --release + +cargo build --release --target x86_64-pc-windows-gnu + +echo "Packaging Linux..." +mkdir -p pm-linux-mac +cp target/release/pm linux-mac-install.sh linux-mac-uninstall.sh pm-linux-mac/ +tar -czvf pm-linux-mac.tar.gz pm-linux-mac/ + +echo "Packaging Windows..." +mkdir -p pm-windows +cp target/x86_64-pc-windows-gnu/release/pm.exe windows-install.ps1 windows-uninstall.ps1 pm-windows/ +zip -r pm-windows.zip pm-windows/ + +rm -rf pm-linux-mac pm-windows +echo "Done! Upload pm-linux-mac.tar.gz and pm-windows.zip to GitHub." diff --git a/src/args.rs b/src/args.rs index 5c5f7bd..d221048 100644 --- a/src/args.rs +++ b/src/args.rs @@ -3,9 +3,20 @@ use clap::{Args, Parser, Subcommand}; #[derive(Parser)] #[command(name = "PassManager")] #[command(about = " A simple password manager CLI", long_about = None)] +#[command(before_help = r#" + ████████ █████████████ _~^~^~_ +▒▒███▒▒███▒▒███▒▒███▒▒███ \) / o o \ (/ + ▒███ ▒███ ▒███ ▒███ ▒███ '_ - _' + ▒███ ▒███ ▒███ ▒███ ▒███ / '-----' \ + ▒███████ █████▒███ █████ + ▒███▒▒▒ ▒▒▒▒▒ ▒▒▒ ▒▒▒▒▒ + ▒███ + █████ +▒▒▒▒▒ +"#)] pub struct Cli { #[command(subcommand)] - pub command: Commands, + pub command: Option, } #[derive(Subcommand)] diff --git a/src/main.rs b/src/main.rs index b6107f2..4523707 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,6 +11,13 @@ use zeroize::Zeroize; fn main() { let cli: Cli = Cli::parse(); + if cli.command.is_none() { + print_banner(); + println!("Welcome to pm - The Rust Password Manager"); + println!("Use 'pm --help' to see available commands."); + return; + } + let home_str = std::env::var("HOME") .or_else(|_| std::env::var("USERPROFILE")) .expect("Could not find home directory"); @@ -76,7 +83,7 @@ fn main() { let mut passwords = storage::load_passwords(file_str, &encryption_key); match &cli.command { - Commands::Add(args) => { + Some(Commands::Add(args)) => { print!("Enter password for {} : ", args.name); std::io::stdout().flush().expect("Flush failed"); let mut p1 = read_password().expect("Failed to read password"); @@ -95,14 +102,14 @@ fn main() { p1.zeroize(); p2.zeroize(); } - Commands::Get(args) => match passwords.get(&args.name) { + Some(Commands::Get(args)) => match passwords.get(&args.name) { Some(pw) => println!("Password for {} : {}", args.name, pw), None => println!("No password found for '{}'", args.name), }, - Commands::Delete(args) => { + Some(Commands::Delete(args)) => { storage::delete_password(file_str, &args.name, &encryption_key); } - Commands::List => { + Some(Commands::List) => { if passwords.is_empty() { println!("No passwords saved yet!"); } else { @@ -113,6 +120,7 @@ fn main() { println!("-----------------------"); } } + None => unreachable!(), } encryption_key.zeroize(); @@ -121,3 +129,18 @@ fn main() { v.zeroize(); } } + +fn print_banner() { + let banner = r#" + ████████ █████████████ _~^~^~_ + ▒▒███▒▒███▒▒███▒▒███▒▒███ \) / o o \ (/ + ▒███ ▒███ ▒███ ▒███ ▒███ '_ - _' + ▒███ ▒███ ▒███ ▒███ ▒███ / '-----' \ + ▒███████ █████▒███ █████ + ▒███▒▒▒ ▒▒▒▒▒ ▒▒▒ ▒▒▒▒▒ + ▒███ + █████ + ▒▒▒▒▒ + "#; + println!("{}", banner); +} diff --git a/windows-install.ps1 b/windows-install.ps1 new file mode 100644 index 0000000..dba3b37 --- /dev/null +++ b/windows-install.ps1 @@ -0,0 +1,12 @@ +$binary = "pm.exe" + +if (Test-Path ".\$binary") { + $binDir = "$HOME\.cargo\bin" + if (!(Test-Path $binDir)) { New-Item -ItemType Directory -Path $binDir } + + Write-Host "Installing $binary to $binDir..." -ForegroundColor Cyan + Copy-Item ".\$binary" "$binDir" + Write-Host "Done! Restart your terminal and type 'pm'." -ForegroundColor Green +} else { + Write-Host "Error: $binary not found in this folder." -ForegroundColor Red +} diff --git a/windows-uninstall.ps1 b/windows-uninstall.ps1 new file mode 100644 index 0000000..1f68fa4 --- /dev/null +++ b/windows-uninstall.ps1 @@ -0,0 +1,4 @@ +Write-Host "Uninstalling pm..." -ForegroundColor Cyan +Remove-Item "$HOME\.cargo\bin\pm.exe" -ErrorAction SilentlyContinue +Remove-Item "$HOME\.my_pass_manager" -Recurse -Force -ErrorAction SilentlyContinue +Write-Host "pm and all encrypted data have been removed." -ForegroundColor Yellow