Added a welcome message when typing pm and added some ascii art

This commit is contained in:
ManOfGoldForever 2026-02-02 00:05:09 -05:00
parent 4b8d4eb0c6
commit 62caefcd22
9 changed files with 95 additions and 5 deletions

11
linux-mac-install.sh Executable file
View file

@ -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

5
linux-mac-uninstall.sh Executable file
View file

@ -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."

Binary file not shown.

Binary file not shown.

24
release.sh Executable file
View file

@ -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."

View file

@ -3,9 +3,20 @@ use clap::{Args, Parser, Subcommand};
#[derive(Parser)] #[derive(Parser)]
#[command(name = "PassManager")] #[command(name = "PassManager")]
#[command(about = " A simple password manager CLI", long_about = None)] #[command(about = " A simple password manager CLI", long_about = None)]
#[command(before_help = r#"
_~^~^~_
\) / o o \ (/
'_ - _'
/ '-----' \
"#)]
pub struct Cli { pub struct Cli {
#[command(subcommand)] #[command(subcommand)]
pub command: Commands, pub command: Option<Commands>,
} }
#[derive(Subcommand)] #[derive(Subcommand)]

View file

@ -11,6 +11,13 @@ use zeroize::Zeroize;
fn main() { fn main() {
let cli: Cli = Cli::parse(); 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") let home_str = std::env::var("HOME")
.or_else(|_| std::env::var("USERPROFILE")) .or_else(|_| std::env::var("USERPROFILE"))
.expect("Could not find home directory"); .expect("Could not find home directory");
@ -76,7 +83,7 @@ fn main() {
let mut passwords = storage::load_passwords(file_str, &encryption_key); let mut passwords = storage::load_passwords(file_str, &encryption_key);
match &cli.command { match &cli.command {
Commands::Add(args) => { Some(Commands::Add(args)) => {
print!("Enter password for {} : ", args.name); print!("Enter password for {} : ", args.name);
std::io::stdout().flush().expect("Flush failed"); std::io::stdout().flush().expect("Flush failed");
let mut p1 = read_password().expect("Failed to read password"); let mut p1 = read_password().expect("Failed to read password");
@ -95,14 +102,14 @@ fn main() {
p1.zeroize(); p1.zeroize();
p2.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), Some(pw) => println!("Password for {} : {}", args.name, pw),
None => println!("No password found for '{}'", args.name), None => println!("No password found for '{}'", args.name),
}, },
Commands::Delete(args) => { Some(Commands::Delete(args)) => {
storage::delete_password(file_str, &args.name, &encryption_key); storage::delete_password(file_str, &args.name, &encryption_key);
} }
Commands::List => { Some(Commands::List) => {
if passwords.is_empty() { if passwords.is_empty() {
println!("No passwords saved yet!"); println!("No passwords saved yet!");
} else { } else {
@ -113,6 +120,7 @@ fn main() {
println!("-----------------------"); println!("-----------------------");
} }
} }
None => unreachable!(),
} }
encryption_key.zeroize(); encryption_key.zeroize();
@ -121,3 +129,18 @@ fn main() {
v.zeroize(); v.zeroize();
} }
} }
fn print_banner() {
let banner = r#"
_~^~^~_
\) / o o \ (/
'_ - _'
/ '-----' \
"#;
println!("{}", banner);
}

12
windows-install.ps1 Normal file
View file

@ -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
}

4
windows-uninstall.ps1 Normal file
View file

@ -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