diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..0676718 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,17 @@ + +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [0.3.0] - 2024-01-04 + +- Refactor: renamed mpm to libmpm and mpm-cli to mpm + +## [0.2.0] - 2024-01-04 + +- Initial release diff --git a/Cargo.toml b/Cargo.toml index 4e72b1b..7aa1521 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,3 @@ [workspace] resolver = "2" -members = ["mpm", "mpm-cli"] -exclude = ["*.png"] +members = ["libmpm", "mpm"] diff --git a/README.md b/README.md index 3e3c14c..7a40c1a 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ ahead in functionality. ## Basic Usage ```rust -use mpm::{managers, Package, PackageManager, Operation}; +use libmpm::{managers, Package, PackageManager, Operation}; fn main() { let brew = managers::HomeBrew; // no constructor is called because it's a unit struct @@ -49,7 +49,7 @@ fn main() { ## Advanced usage ```rust -use mpm::{managers, verify::Verify, Cmd, Commands, PackageManager}; +use libmpm::{managers, verify::Verify, Cmd, Commands, PackageManager}; fn main() { // creating a verified instance (package manager known to be in path/installed) @@ -69,7 +69,7 @@ fn main() { // fully customize commands with the general purpose `consolidated_args` fn // this example is impractical, but it shows how you can mix custom commands with default ones // default command is retrieved for `List` and default flags for `Install` - let cmds = mpm::consolidate_args( + let cmds = libmpm::consolidate_args( verified.get_cmds(Cmd::List), &["anything"], verified.get_flags(Cmd::Install), diff --git a/libmpm/Cargo.toml b/libmpm/Cargo.toml new file mode 100644 index 0000000..c2ec0d5 --- /dev/null +++ b/libmpm/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "libmpm" +version = "0.3.0" +edition = "2021" +license = "AGPL-3.0" + +[features] +default = ["verify"] +verify = [] +choco = [] +brew = [] +apt = [] +dnf = [] +yum = ["dnf"] + + +[dependencies] + +[[test]] +name = "basic" +required-features = ["verify", "choco", "brew", "apt", "dnf", "yum"] diff --git a/mpm-cli/LICENSE b/libmpm/LICENSE similarity index 100% rename from mpm-cli/LICENSE rename to libmpm/LICENSE diff --git a/mpm/src/lib.rs b/libmpm/src/lib.rs similarity index 99% rename from mpm/src/lib.rs rename to libmpm/src/lib.rs index 56bfc8a..d12e9f7 100644 --- a/mpm/src/lib.rs +++ b/libmpm/src/lib.rs @@ -1,4 +1,3 @@ -#![doc = include_str!("libdoc.md")] use std::{ borrow::Cow, error::Error, diff --git a/mpm/src/libtests.rs b/libmpm/src/libtests.rs similarity index 100% rename from mpm/src/libtests.rs rename to libmpm/src/libtests.rs diff --git a/mpm/src/managers.rs b/libmpm/src/managers.rs similarity index 100% rename from mpm/src/managers.rs rename to libmpm/src/managers.rs diff --git a/mpm/src/managers/apt.rs b/libmpm/src/managers/apt.rs similarity index 100% rename from mpm/src/managers/apt.rs rename to libmpm/src/managers/apt.rs diff --git a/mpm/src/managers/brew.rs b/libmpm/src/managers/brew.rs similarity index 100% rename from mpm/src/managers/brew.rs rename to libmpm/src/managers/brew.rs diff --git a/mpm/src/managers/choco.rs b/libmpm/src/managers/choco.rs similarity index 100% rename from mpm/src/managers/choco.rs rename to libmpm/src/managers/choco.rs diff --git a/mpm/src/managers/dnf.rs b/libmpm/src/managers/dnf.rs similarity index 100% rename from mpm/src/managers/dnf.rs rename to libmpm/src/managers/dnf.rs diff --git a/mpm/src/managers/yum.rs b/libmpm/src/managers/yum.rs similarity index 100% rename from mpm/src/managers/yum.rs rename to libmpm/src/managers/yum.rs diff --git a/mpm/src/verify.rs b/libmpm/src/verify.rs similarity index 100% rename from mpm/src/verify.rs rename to libmpm/src/verify.rs diff --git a/mpm/tests/basic.rs b/libmpm/tests/basic.rs similarity index 98% rename from mpm/tests/basic.rs rename to libmpm/tests/basic.rs index c8505d2..788a2a0 100644 --- a/mpm/tests/basic.rs +++ b/libmpm/tests/basic.rs @@ -1,5 +1,5 @@ -use mpm::verify::Verify; -use mpm::*; +use libmpm::verify::Verify; +use libmpm::*; #[cfg(feature = "brew")] #[cfg(not(target_os = "windows"))] diff --git a/mpm-cli/Cargo.toml b/mpm-cli/Cargo.toml deleted file mode 100644 index 58b2357..0000000 --- a/mpm-cli/Cargo.toml +++ /dev/null @@ -1,26 +0,0 @@ -[package] -name = "mpm-cli" -version = "0.2.0" -edition = "2021" -license = "AGPL-3.0" - -[[bin]] -name = "mpm" -path = "src/main.rs" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -anyhow = "1.0.75" -clap = { version = "4.4.6", features = ["derive"] } -colored = "2.0.4" -strum = { version = "0.25.0", features = ["derive"] } -tabled = { version = "0.14.0", features = ["color"] } -mpm = { path = "../mpm", features = [ - "verify", - "brew", - "choco", - "apt", - "dnf", - "yum", -] } diff --git a/mpm-cli/Cargo.lock b/mpm/Cargo.lock similarity index 100% rename from mpm-cli/Cargo.lock rename to mpm/Cargo.lock diff --git a/mpm/Cargo.toml b/mpm/Cargo.toml index e0ac041..da6f267 100644 --- a/mpm/Cargo.toml +++ b/mpm/Cargo.toml @@ -1,21 +1,20 @@ [package] name = "mpm" -version = "0.2.0" +version = "0.3.0" edition = "2021" license = "AGPL-3.0" -[features] -default = ["verify"] -verify = [] -choco = [] -brew = [] -apt = [] -dnf = [] -yum = ["dnf"] - - [dependencies] - -[[test]] -name = "basic" -required-features = ["verify", "choco", "brew", "apt", "dnf", "yum"] +anyhow = "1.0.75" +clap = { version = "4.4.6", features = ["derive"] } +colored = "2.0.4" +strum = { version = "0.25.0", features = ["derive"] } +tabled = { version = "0.14.0", features = ["color"] } +libmpm = { path = "../libmpm", features = [ + "verify", + "brew", + "choco", + "apt", + "dnf", + "yum", +] } diff --git a/mpm/src/libdoc.md b/mpm/src/libdoc.md deleted file mode 100644 index f6450fb..0000000 --- a/mpm/src/libdoc.md +++ /dev/null @@ -1,75 +0,0 @@ -# genpack -A generic package manager for interfacing with multiple distro/platform specific package managers. - -All package manager wrappers are placed behind feature flags, so you can enable only the ones you need. - -## Basic Usage -```no_run -use mpm::{managers, Package, PackageManager, Operation}; -# #[cfg(feature = "brew")] -# { -let brew = managers::Homebrew; // no constructor is called because it's a unit struct - -// Important: running any commands through the package manager if it is not in path/not installed -// will result in a panic. See advanced usage for safely constructing verified instances. - -// single package operation (blocking call) -brew.install("mypackage".into()); -brew.install(Package::from("packwithver").with_version("1.0.0")); - -// most methods return `ExitStatus` which can be used to check if -// the operation was successful -if brew.update_all().success() { - println!("All packages updated/upgraded"); -} - -// multi pacakge operation (blocking call) -brew.exec_op( - &["mypackage".into(), "packwithver".into()], - Operation::Uninstall, -); - -// get packages matching search string -for p in brew.search("python") { - println!("{p}"); -} - -// list installed packages -for p in brew.list_installed() { - println!("{p}"); -} -# } -``` - -## Advanced usage -```no_run -# #[cfg(all(feature = "verify", feature = "choco"))] -use mpm::{managers, verify::Verify, Cmd, Commands, PackageManager}; - -# #[cfg(all(feature = "verify", feature = "choco"))] -# { -// creating a verified instance (package manager known to be in path/installed) -// requires enabling the feature `verify` -let Some(verified) = managers::Chocolatey.verify() else { - return println!("HomeBrew not in path / not installed"); -}; - -// get output by manually executing package manager commands (blocking call) -let cmds = verified.consolidated(Cmd::Install, &["mypacakge"]); // gets appropriate Install command and flags -let _output = verified.exec_cmds(&cmds); - -// get handle to child process (non-blocking) -let cmds = verified.consolidated(Cmd::Update, &["some", "packages", "--quiet"]); // flags can also be included -let _handle = verified.exec_cmds_spawn(&cmds); - -// fully customize commands with the general purpose `consolidated_args` fn -// this example is impractical, but it shows how you can mix custom commands with default ones -// default command is retrieved for `List` and default flags for `Install` -let cmds = mpm::consolidate_args( - verified.get_cmds(Cmd::List), - &["anything"], - verified.get_flags(Cmd::Install), -); -let _status = verified.exec_cmds_status(&cmds); // blocking call returns ExitStatus -# } -``` \ No newline at end of file diff --git a/mpm-cli/src/main.rs b/mpm/src/main.rs similarity index 100% rename from mpm-cli/src/main.rs rename to mpm/src/main.rs diff --git a/mpm-cli/src/utils.rs b/mpm/src/utils.rs similarity index 99% rename from mpm-cli/src/utils.rs rename to mpm/src/utils.rs index 4c47500..c28905b 100644 --- a/mpm-cli/src/utils.rs +++ b/mpm/src/utils.rs @@ -1,6 +1,6 @@ use anyhow::{bail, Context, Result}; use manager::Manager; -use mpm::{verify::DynVerified, Operation}; +use libmpm::{verify::DynVerified, Operation}; use parser::{Cli, Commands}; use strum::IntoEnumIterator; diff --git a/mpm-cli/src/utils/manager.rs b/mpm/src/utils/manager.rs similarity index 99% rename from mpm-cli/src/utils/manager.rs rename to mpm/src/utils/manager.rs index 33ed122..d9b40fb 100644 --- a/mpm-cli/src/utils/manager.rs +++ b/mpm/src/utils/manager.rs @@ -1,7 +1,7 @@ use std::fmt::Display; use clap::ValueEnum; -use mpm::{ +use libmpm::{ managers::{AdvancedPackageTool, Chocolatey, DandifiedYUM, Homebrew, YellowdogUpdaterModified}, verify::{DynVerified, Verify}, }; diff --git a/mpm-cli/src/utils/parser.rs b/mpm/src/utils/parser.rs similarity index 99% rename from mpm-cli/src/utils/parser.rs rename to mpm/src/utils/parser.rs index c61b701..cc42ee7 100644 --- a/mpm-cli/src/utils/parser.rs +++ b/mpm/src/utils/parser.rs @@ -1,6 +1,6 @@ use super::Manager; use clap::{Parser, Subcommand}; -use mpm::Package; +use libmpm::Package; #[derive(Parser)] #[command( diff --git a/mpm-cli/src/utils/print.rs b/mpm/src/utils/print.rs similarity index 99% rename from mpm-cli/src/utils/print.rs rename to mpm/src/utils/print.rs index d93f13e..3d9cf0e 100644 --- a/mpm-cli/src/utils/print.rs +++ b/mpm/src/utils/print.rs @@ -1,7 +1,7 @@ use super::Manager; use anyhow::Error; use colored::{ColoredString, Colorize}; -use mpm::Package; +use libmpm::Package; use strum::{EnumCount, IntoEnumIterator}; use tabled::{ settings::{object::Rows, themes::Colorization, Color, Style},