Skip to content

Commit

Permalink
release: 0.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
joshstoik1 committed Aug 9, 2024
2 parents b4242f2 + ebd8e9a commit e9572cd
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
RUSTFLAGS: "-D warnings"

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/msrv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
RUSTFLAGS: "-D warnings"

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
Expand Down
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.0](https://github.com/Blobfolio/argyle/releases/tag/v0.8.0) - 2024-08-08

### New

* `Argue::take_trailing`



## [0.7.2](https://github.com/Blobfolio/argyle/releases/tag/v0.7.2) - 2024-02-15

### 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.7.2
Generated: 2024-02-15 20:26:13 UTC
Version: 0.8.0
Generated: 2024-08-09 06:26:25 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.7.2"
version = "0.8.0"
authors = ["Blobfolio, LLC. <[email protected]>"]
edition = "2021"
rust-version = "1.70"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Add `argyle` to your `dependencies` in `Cargo.toml`, like:

```
[dependencies]
argyle = "0.7.*"
argyle = "0.8.*"
```


Expand Down
51 changes: 42 additions & 9 deletions src/argue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,9 @@ impl Argue {
/// If you merely want something to iterate over, you can alternatively
/// dereference the struct to a string slice.
///
/// If you're only interested in the _trailing_ arguments, use
/// `Argue::take_trailing` instead.
///
/// ## Examples
///
/// ```no_run
Expand All @@ -539,6 +542,35 @@ impl Argue {
/// let args: Vec<Vec<u8>> = Argue::new(0).unwrap().take();
/// ```
pub fn take(self) -> Vec<Vec<u8>> { self.args }

#[must_use]
/// # Take Trailing Arguments.
///
/// Split off and return the instance's (owned) trailing arguments,
/// discarding everything else.
///
/// As with other trailing argument-related methods, make sure you query
/// expected options before calling this method, otherwise it might
/// mistake a final associated value for a trailing argument.
///
/// Of course, that matters less here than elsewhere since you'll lose
/// access to the switches and options anyway. Haha.
///
/// If you want _everything_, use `Argue::take` instead.
///
/// ## Examples
///
/// ```no_run
/// use argyle::Argue;
///
/// let trailing: Vec<Vec<u8>> = Argue::new(0).unwrap().take_trailing();
/// ```
pub fn take_trailing(self) -> Vec<Vec<u8>> {
let idx = self.arg_idx();
let Self { mut args, .. } = self;
args.drain(..idx);
args
}
}

/// ## Queries.
Expand Down Expand Up @@ -1116,15 +1148,6 @@ mod tests {
// Let's see what trailing args look like when there are none.
assert_eq!(args.arg(0), None);

// Let's also make sure the trailing arguments work too.
let trailing: &[&[u8]] = &[b"Hello", b"World"];
base.extend_from_slice(trailing);
args = base.iter().copied().collect();
assert_eq!(args.arg(0), Some(&b"Hello"[..]));
assert_eq!(args.arg(1), Some(&b"World"[..]));
assert_eq!(args.arg(2), None);
assert_eq!(args.args(), trailing);

// If there are no keys, the first entry should also be the first
// argument.
args = [b"hello".to_vec()].into_iter().collect();
Expand All @@ -1133,6 +1156,16 @@ mod tests {
// Unless we're expecting a subcommand...
args.flags |= FLAG_SUBCOMMAND;
assert!(args.arg(0).is_none());

// Let's also make sure the trailing arguments work too.
let trailing: &[&[u8]] = &[b"Hello", b"World"];
base.extend_from_slice(trailing);
args = base.iter().copied().collect();
assert_eq!(args.arg(0), Some(&b"Hello"[..]));
assert_eq!(args.arg(1), Some(&b"World"[..]));
assert_eq!(args.arg(2), None);
assert_eq!(args.args(), trailing);
assert_eq!(args.take_trailing(), trailing); // This should match too.
}

#[test]
Expand Down

0 comments on commit e9572cd

Please sign in to comment.