diff --git a/README.md b/README.md index 1959de8..75fa96c 100644 --- a/README.md +++ b/README.md @@ -1,74 +1,103 @@ -# ๐ŸŒŸ lpkg CLI Roadmap ๐ŸŒˆ +# ๐Ÿงฌ LPKG โ€“ Lightweight Package Manager -`lpkg` is going to have a cute, intuitive, and powerful CLI to **bootstrap environments** and **manage packages**. Each command is themed with emojis to make your workflow extra magical ๐Ÿ’–โœจ. +LPKG is a minimalistic package manager written in Rust, designed for fast and simple software management on Unix-like systems. It emphasizes reproducibility and declarative configuration, leveraging **Nix Flakes** for development and deployment. --- -## โœจ Core Commands +## ๐Ÿš€ Features -| Command | Emoji | Description | -| -------------------- | ----- | ------------------------------------------------- | -| `lpkg init` | ๐ŸŒฑ | Bootstraps a new environment from scratch | -| `lpkg setup` | ๐Ÿ›  | Sets up packages, dependencies, and config files | -| `lpkg install ` | ๐Ÿ“ฆ | Installs a package | -| `lpkg update ` | ๐Ÿ”„ | Updates a package to the latest version | -| `lpkg remove ` | โŒ | Removes a package | -| `lpkg list` | ๐Ÿ“œ | Lists all installed packages | -| `lpkg status` | ๐Ÿ” | Shows the status of your environment and packages | +* **Fast & Lightweight** โ€“ Minimal resource usage and quick operations. +* **Rust-Powered** โ€“ Safe and concurrent code with Rust. +* **Cross-Platform** โ€“ Works on Linux and macOS. +* **Declarative Builds** โ€“ Fully reproducible with Nix Flakes. +* **Simple CLI** โ€“ Intuitive commands for managing packages. --- -## ๐ŸŒˆ Advanced & Magical Commands +## โš™๏ธ Installation -| Command | Emoji | Description | -| ---------------- | ----- | ------------------------------------------------------------------------- | -| `lpkg bootstrap` | ๐Ÿš€ | Full bootstrapping + package installation in one magical command | -| `lpkg doctor` | ๐Ÿฉบ | Checks your system for missing dependencies or broken configs | -| `lpkg clean` | ๐Ÿงน | Cleans up cache, temp files, and old builds | -| `lpkg export` | โœจ๐Ÿ“ฆ | Exports a manifest of installed packages (for sharing your magical setup) | -| `lpkg import` | โœจ๐Ÿ“ฅ | Imports a manifest to reproduce an environment exactly | - ---- - -## ๐Ÿ’ซ Example Workflows - -### 1๏ธโƒฃ Bootstrapping a new environment +### Using Cargo ```bash -lpkg init ๐ŸŒฑ -lpkg setup ๐Ÿ›  -lpkg install neovim ๐Ÿ“ฆ -lpkg install starship ๐Ÿ“ฆ -lpkg status ๐Ÿ” +cargo install lpkg ``` -### 2๏ธโƒฃ Updating packages +### Using Nix Flakes + +If you have Nix with flakes enabled: ```bash -lpkg update starship ๐Ÿ”„ -lpkg update neovim ๐Ÿ”„ +nix profile install github:lesbiannix/lpkg ``` -### 3๏ธโƒฃ Cleaning up old stuff +Or to run without installing: ```bash -lpkg clean ๐Ÿงน -``` - -### 4๏ธโƒฃ Sharing your magical setup - -```bash -lpkg export โœจ๐Ÿ“ฆ > my-setup.yaml -lpkg import โœจ๐Ÿ“ฅ my-setup.yaml +nix run github:lesbiannix/lpkg ``` --- -## ๐Ÿš€ Future CLI Enhancements +## ๐Ÿงฐ Usage -* ๐Ÿณ๏ธโ€โšง๏ธ Interactive CLI mode (`lpkg magic-mode โœจ`) -* ๐ŸŒˆ Auto-detect missing packages and suggest fixes (`lpkg auto-fix ๐Ÿ”ฎ`) -* ๐Ÿ’– CLI themes with rainbow colors, cute prompts, and ASCII art ๐Ÿ’ซ -* ๐Ÿ“ฆ Integration with Nix flakes for fully reproducible environments +Basic command structure: + +```bash +lpkg [command] [package] +``` + +Common commands: + +* `install` โ€“ Install a package +* `remove` โ€“ Remove a package +* `update` โ€“ Update the package list +* `upgrade` โ€“ Upgrade all installed packages + +For detailed usage: + +```bash +lpkg --help +``` + +--- + +## ๐Ÿ”ง Development with Flakes + +Clone the repository: + +```bash +git clone https://github.com/lesbiannix/lpkg.git +cd lpkg +``` + +Enter the flake development shell: + +```bash +nix develop +``` + +Build the project: + +```bash +cargo build +``` + +Run tests: + +```bash +cargo test +``` + +You can also run the project directly in the flake shell: + +```bash +nix run +``` + +--- + +## ๐Ÿ“„ License + +LPKG is licensed under the [MIT License](LICENSE). diff --git a/src/downloader.rs b/src/downloader.rs deleted file mode 100644 index 0634a04..0000000 --- a/src/downloader.rs +++ /dev/null @@ -1,63 +0,0 @@ -use anyhow::{Result, anyhow}; -use std::collections::HashMap; -use std::fs::{self, File}; -use std::io::{Read, Write}; -use std::path::Path; -use std::thread; - -pub fn download_files( - files: &[String], - target_dir: &Path, - mirror: Option<&str>, - md5_map: Option<&HashMap>, -) -> Result<()> { - fs::create_dir_all(target_dir)?; - - let mut handles = vec![]; - - for url in files.iter().cloned() { - let target_dir = target_dir.to_path_buf(); - let mirror = mirror.map(|m| m.to_string()); - let md5_map = md5_map.cloned(); - - let handle = thread::spawn(move || -> Result<()> { - let download_url = if let Some(m) = &mirror { - url.replace("ftp.gnu.org", m) - } else { - url.clone() - }; - - let filename = download_url - .split('/') - .last() - .ok_or_else(|| anyhow!("Failed to extract filename"))?; - let filepath = target_dir.join(filename); - - let mut resp = reqwest::blocking::get(&download_url)?; - let mut buffer = Vec::new(); - resp.read_to_end(&mut buffer)?; - - let mut file = File::create(&filepath)?; - file.write_all(&buffer)?; - - if let Some(md5s) = md5_map.as_ref() { - if let Some(expected) = md5s.get(filename) { - let digest = md5::compute(&buffer); - if format!("{:x}", digest) != *expected { - return Err(anyhow!("MD5 mismatch for {}", filename)); - } - } - } - - Ok(()) - }); - - handles.push(handle); - } - - for handle in handles { - handle.join().map_err(|_| anyhow!("Thread panicked"))??; - } - - Ok(()) -} diff --git a/src/main.rs b/src/main.rs index 9f7ffce..3146749 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,6 @@ use tracing::{error, info}; use tracing_appender::rolling::{RollingFileAppender, Rotation}; use tracing_subscriber::{EnvFilter, fmt, prelude::*}; -mod downloader; mod tui; mod wget_list;