Skip to content

Commit

Permalink
Release '0.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
hwittenborn committed Jul 23, 2022
1 parent 7910db9 commit ba980ee
Show file tree
Hide file tree
Showing 12 changed files with 168 additions and 56 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.5.0] - 2022-07-23
### Added
- Added `update` command.

## [0.4.2] - 2022-07-11
Internal changes used to test CI. No changes have been made for end users.

Expand Down
19 changes: 15 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ categories = ["command-line-utilities"]

[dependencies]
bat = "0.21.0"
ansi_term = "0.12.1"
colored = { git = "https://github.com/mackwic/colored" }
chrono = "0.4.19"
clap = { version = "3.2.8", features = ["cargo", "env"] }
dirs = "4.0.0"
edit = "0.1.4"
exitcode = "1.1.2"
flate2 = "1.0.24"
lazy_static = "1.4.0"
quit = "1.1.4"
regex = "1.6.0"
reqwest = { version = "0.11.11", features = ["blocking", "json"] }
Expand Down
10 changes: 10 additions & 0 deletions completions/mpr.bash
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ _mpr() {
'info'
'list-comments'
'search'
'update'
'whoami'
)
local opts=(
Expand Down Expand Up @@ -125,6 +126,15 @@ _mpr() {
;;
esac
;;
update)
case "${prev}" in
--token|--mpr-url)
return
;;
esac

_mpr_gen_compreply '${opts[@]}' "${cur}"
;;
whoami)
case "${prev}" in
--token|--mpr-url)
Expand Down
2 changes: 1 addition & 1 deletion makedeb/PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Maintainer: Hunter Wittenborn <[email protected]>
pkgname=mpr-cli
pkgver=0.4.2
pkgver=0.5.0
pkgrel=1
pkgdesc='The official command-line interface for the makedeb Package Repository'
arch=('any')
Expand Down
4 changes: 4 additions & 0 deletions man/mpr.1.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ mpr - The official command-line interface for the makedeb Package Repository
*mpr* info _pkgname_ [_options_] ...
*mpr* list-comments _pkgbase_ [_options_] ...
*mpr* search _query_ ... [_options_] ...
*mpr* update
*mpr* whoami [_options_] ...

== DESCRIPTION
Expand All @@ -35,6 +36,9 @@ List comments of a package base on the MPR.
*search*::
Search the package list on the MPR.

*update*::
Updates the APT cache on the system. The MPR cache is not updated as part of this process, as it automatically gets updated when needed commands find it to be old.

*whoami*::
Show the currently authenticated user.

Expand Down
2 changes: 1 addition & 1 deletion src/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub fn clone(args: &clap::ArgMatches) {
)
);

message::error_bold(&format!(" {} clone '{}'", clap::crate_name!(), pkgbase));
message::error(&format!(" {} clone '{}'", clap::crate_name!(), pkgbase));
}

None => (),
Expand Down
8 changes: 8 additions & 0 deletions src/color.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
pub use colored::Colorize;
use colored::CustomColor;
use lazy_static::lazy_static;

lazy_static! {
pub static ref UBUNTU_ORANGE: CustomColor = CustomColor::new(255, 175, 0);
pub static ref UBUNTU_PURPLE: CustomColor = CustomColor::new(95, 95, 255);
}
7 changes: 7 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
mod cache;
mod clone;
mod color;
mod comment;
mod info;
mod list_comments;
mod message;
mod pkglist;
mod search;
mod update;
mod util;
mod whoami;

Expand Down Expand Up @@ -125,6 +127,10 @@ fn get_cli() -> Command<'static> {
.long("mpr-only")
)
)
.subcommand(
Command::new("update")
.about("Update the APT cache on the system")
)
.subcommand(
Command::new("whoami")
.about("Show the currently authenticated user")
Expand All @@ -142,6 +148,7 @@ fn main() {
Some(("list-comments", args)) => list_comments::list_comments(args),
Some(("pkglist", args)) => pkglist::pkglist(args),
Some(("search", args)) => search::search(args),
Some(("update", args)) => update::update(args),
Some(("whoami", args)) => whoami::whoami(args),
_ => {}
};
Expand Down
16 changes: 6 additions & 10 deletions src/message.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
use ansi_term::{Colour, Style};
use crate::color::Colorize;

pub fn info(str: &str) {
println!("{}", str);
println!("{} {}", "Info:".cyan().bold(), str);
}

pub fn error(str: &str) {
println!("{} {}", Colour::Red.paint("Err:"), str);
pub fn warning(str: &str) {
println!("{} {}", "Err:".yellow().bold(), str);
}

pub fn error_bold(str: &str) {
println!(
"{} {}",
Colour::Red.paint("Err:"),
Style::new().bold().paint(str)
);
pub fn error(str: &str) {
println!("{} {}", "Err:".red().bold(), str);
}
53 changes: 14 additions & 39 deletions src/search.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::{
cache::{Cache, CachePackage, CachePackageSource, MprCache},
color::{self, Colorize},
message,
};
use ansi_term::{Colour, Style};
use chrono::{TimeZone, Utc};
use rust_apt::cache::Cache as AptCache;
use std::{collections::HashMap, fmt::Write};
Expand Down Expand Up @@ -131,7 +131,12 @@ pub fn pkg_info(package_map: &HashMap<&String, Vec<&CachePackage>>, pkg_str: &St
let mut sources_str = String::from("[");

for source in sources {
write!(sources_str, "{}, ", Colour::Fixed(63).paint(source)).unwrap();
write!(
sources_str,
"{}, ",
source.custom_color(*color::UBUNTU_PURPLE)
)
.unwrap();
}

// Remove the trailing ', ' at the end of the string. Then add the closing ']'.
Expand All @@ -143,7 +148,7 @@ pub fn pkg_info(package_map: &HashMap<&String, Vec<&CachePackage>>, pkg_str: &St
writeln!(
result,
"{}/{} {}",
Colour::Fixed(214).paint(pkg.pkgname.as_str()),
pkg.pkgname.as_str().custom_color(*color::UBUNTU_ORANGE),
pkg.version,
sources_str
)
Expand All @@ -152,13 +157,7 @@ pub fn pkg_info(package_map: &HashMap<&String, Vec<&CachePackage>>, pkg_str: &St
// pkgdesc.
match &pkg.pkgdesc {
Some(pkgdesc) => {
writeln!(
result,
"{} {}",
Style::new().bold().paint("Description:"),
pkgdesc
)
.unwrap();
writeln!(result, "{} {}", "Description:".bold(), pkgdesc).unwrap();
}

None => (),
Expand All @@ -167,40 +166,22 @@ pub fn pkg_info(package_map: &HashMap<&String, Vec<&CachePackage>>, pkg_str: &St
// Maintainer.
match &pkg.maintainer {
Some(maintainer) => {
writeln!(
result,
"{} {}",
Style::new().bold().paint("Maintainer:"),
maintainer
)
.unwrap();
writeln!(result, "{} {}", "Maintainer:".bold(), maintainer).unwrap();
}

None => (),
}

// Votes.
match &pkg.num_votes {
Some(num_votes) => writeln!(
result,
"{} {}",
Style::new().bold().paint("Votes:"),
num_votes
)
.unwrap(),
Some(num_votes) => writeln!(result, "{} {}", "Votes:".bold(), num_votes).unwrap(),

None => (),
}

// Popularity.
match &pkg.popularity {
Some(popularity) => writeln!(
result,
"{} {}",
Style::new().bold().paint("Popularity:"),
popularity
)
.unwrap(),
Some(popularity) => writeln!(result, "{} {}", "Popularity:".bold(), popularity).unwrap(),

None => (),
}
Expand All @@ -210,17 +191,11 @@ pub fn pkg_info(package_map: &HashMap<&String, Vec<&CachePackage>>, pkg_str: &St
match &pkg.ood {
Some(ood) => {
let dt = Utc.timestamp(*ood as i64, 0).format("%Y-%m-%d").to_string();
writeln!(
result,
"{} {}",
Style::new().bold().paint("Out of Date:"),
dt
)
.unwrap();
writeln!(result, "{} {}", "Out of Date:".bold(), dt).unwrap();
}

None => {
writeln!(result, "{} N/A", Style::new().bold().paint("Out of Date:")).unwrap();
writeln!(result, "{} N/A", "Out of Date:".bold()).unwrap();
}
}
}
Expand Down
Loading

0 comments on commit ba980ee

Please sign in to comment.