Skip to content

Commit

Permalink
release: 0.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
joshstoik1 committed Sep 5, 2024
2 parents e9572cd + 51804b2 commit 2d97404
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 20 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@



## [0.8.1](https://github.com/Blobfolio/argyle/releases/tag/v0.8.1) - 2024-09-05

### Changed

* Minor code changes and lints



## [0.8.0](https://github.com/Blobfolio/argyle/releases/tag/v0.8.0) - 2024-08-08

### New
Expand Down
4 changes: 2 additions & 2 deletions CREDITS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Project Dependencies
Package: argyle
Version: 0.8.0
Generated: 2024-08-09 06:26:25 UTC
Version: 0.8.1
Generated: 2024-09-05 18:45:10 UTC

This package has no dependencies.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "argyle"
version = "0.8.0"
version = "0.8.1"
authors = ["Blobfolio, LLC. <[email protected]>"]
edition = "2021"
rust-version = "1.70"
Expand Down
6 changes: 3 additions & 3 deletions examples/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ use std::os::unix::ffi::OsStrExt;

fn main() {
println!("Struct size: {}", size_of::<argyle::Argue>());
println!("");
println!();

let args = argyle::Argue::new(argyle::FLAG_REQUIRED);
match args {
Ok(a) => {
println!("\x1b[2mRAW:\x1b[0m");
println!("{:?}", a);

println!("");
println!();
println!("\x1b[2mPRETTY:\x1b[0m");

a.take().iter().for_each(|b| {
println!("{}", OsStr::from_bytes(b).to_str().unwrap_or("[Invalid UTF-8]"));
});

println!("");
println!();
},
Err(e) => {
println!("Error: {}", e);
Expand Down
2 changes: 1 addition & 1 deletion examples/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn main() {
std::process::exit(1);
}

println!("");
println!();
},
Err(e) => {
println!("\x1b[1;91mError:\x1b[0m {e}");
Expand Down
3 changes: 3 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ bench BENCH="":
# Clippy.
@clippy:
clear
cargo clippy \
--all-features \
--target-dir "{{ cargo_dir }}"
cargo clippy \
--release \
--all-features \
Expand Down
12 changes: 6 additions & 6 deletions src/argue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,6 @@ impl Argue {
///
/// These methods convert `Argue` into different data structures.
impl Argue {
#[allow(clippy::missing_const_for_fn)] // Doesn't work!
#[must_use]
#[inline]
/// # Into Owned Vec.
Expand Down Expand Up @@ -1074,6 +1073,7 @@ mod tests {
use brunch as _;

#[test]
#[allow(clippy::cognitive_complexity)] // It is what it is.
fn t_parse_args() {
let mut base: Vec<&[u8]> = vec![
b"hey",
Expand Down Expand Up @@ -1150,7 +1150,7 @@ mod tests {

// If there are no keys, the first entry should also be the first
// argument.
args = [b"hello".to_vec()].into_iter().collect();
args = std::iter::once(b"hello".to_vec()).collect();
assert_eq!(args.arg(0), Some(&b"hello"[..]));

// Unless we're expecting a subcommand...
Expand Down Expand Up @@ -1212,7 +1212,7 @@ mod tests {
b"--one-more",
];

let args = base.iter().cloned().collect::<Argue>();
let args = base.iter().copied().collect::<Argue>();
assert_eq!(args.switch_by_prefix(b"--dump"), Some(&b"-three"[..]));
assert_eq!(args.switch_by_prefix(b"--dump-"), Some(&b"three"[..]));
assert_eq!(args.switch_by_prefix(b"--with"), None);
Expand Down Expand Up @@ -1494,12 +1494,12 @@ mod tests {
let base: Vec<&[u8]> = vec![ b"foo" ];

// As is.
let args = base.iter().cloned().collect::<Argue>();
let args = base.iter().copied().collect::<Argue>();
assert_eq!(args.args(), base);

// With extra stuff.
let args = base.iter().cloned().collect::<Argue>()
.with_trailing_args(&[
let args = base.iter().copied().collect::<Argue>()
.with_trailing_args([
"bar",
" baz ", // Should be trimmed.
" ", // Should be ignored.
Expand Down
29 changes: 29 additions & 0 deletions src/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ use std::{
///
/// This iterates through the arguments of an [`Argue`](crate::Argue) as [`OsStr`](std::ffi::OsStr) values.
pub struct ArgsOsStr<'a> {
/// # Slice.
///
/// A borrowed copy of the arguments, as a slice.
inner: &'a [Vec<u8>],

/// # Next Index.
///
/// The position of the next argument to pull, i.e. `inner[pos]`. The value
/// is incremented after each successful fetch.
pos: usize,
}

Expand Down Expand Up @@ -64,10 +72,31 @@ impl<'a> ArgsOsStr<'a> {
///
/// It is the return value for [`Argue::option_values`](crate::Argue::option_values) and [`Argue::option2_values`](crate::Argue::option2_values).
pub struct Options<'a> {
/// # Found-but-Unyielded Values.
///
/// If iteration encounters more values than it can return, the extras are
/// added to this buffer so they can be yielded on subsequent passes.
buf: Vec<&'a [u8]>,

/// # Slice.
///
/// A borrowed copy of the arguments. Note iteration potentially shrinks
/// this slice. If both it and `buf` are empty, iteration is done.
inner: &'a [Vec<u8>],

/// # Needle.
///
/// Only values corresponding to this key are yielded.
k1: &'a [u8],

/// # Optional Second Needle.
k2: Option<&'a [u8]>,

/// # Value Delimiter.
///
/// If specified, a matching value will be split on this character,
/// potentially yielded multiple values instead of just one. For example,
/// a comma would turn `one,two,three` into `one`, `two`, and `three`.
delimiter: Option<u8>,
}

Expand Down
1 change: 1 addition & 0 deletions src/keykind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ mod tests {
use brunch as _;

#[test]
#[allow(clippy::cognitive_complexity)] // It is what it is.
fn t_from() {
assert_eq!(KeyKind::from(&b"Your Mom"[..]), KeyKind::None);
assert_eq!(KeyKind::from(&b"--"[..]), KeyKind::None);
Expand Down
39 changes: 32 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,29 +67,54 @@ fn _main() -> Result<(), ArgyleError> {

#![forbid(unsafe_code)]

#![deny(
// TODO: clippy::allow_attributes_without_reason,
clippy::correctness,
unreachable_pub,
)]

#![warn(
clippy::filetype_is_file,
clippy::integer_division,
clippy::needless_borrow,
clippy::complexity,
clippy::nursery,
clippy::pedantic,
clippy::perf,
clippy::suboptimal_flops,
clippy::style,
// TODO: clippy::allow_attributes,
clippy::clone_on_ref_ptr,
clippy::create_dir,
clippy::filetype_is_file,
clippy::format_push_string,
clippy::get_unwrap,
clippy::impl_trait_in_params,
clippy::lossy_float_literal,
clippy::missing_assert_message,
clippy::missing_docs_in_private_items,
clippy::needless_raw_strings,
clippy::panic_in_result_fn,
clippy::pub_without_shorthand,
clippy::rest_pat_in_fully_bound_structs,
clippy::semicolon_inside_block,
clippy::str_to_string,
clippy::string_to_string,
clippy::todo,
clippy::undocumented_unsafe_blocks,
clippy::unneeded_field_pattern,
clippy::unseparated_literal_suffix,
clippy::unwrap_in_result,
macro_use_extern_crate,
missing_copy_implementations,
missing_debug_implementations,
missing_docs,
non_ascii_idents,
trivial_casts,
trivial_numeric_casts,
unreachable_pub,
unused_crate_dependencies,
unused_extern_crates,
unused_import_braces,
)]

#![allow(clippy::module_name_repetitions)] // This is fine.
#![allow(clippy::module_name_repetitions)] // Repetition is preferred.

#![cfg_attr(docsrs, feature(doc_cfg))]

Expand Down

0 comments on commit 2d97404

Please sign in to comment.