Skip to content

Commit

Permalink
release: 0.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
joshstoik1 committed Oct 17, 2024
2 parents 0af56cb + e74b66c commit 7ba675f
Show file tree
Hide file tree
Showing 15 changed files with 814 additions and 2,597 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ jobs:
target:
- x86_64-unknown-linux-gnu
- x86_64-apple-darwin
- x86_64-pc-windows-msvc
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest

runs-on: ${{matrix.os}}

Expand Down Expand Up @@ -54,14 +57,11 @@ jobs:
- name: Clippy
run: |
cargo clippy --release --target ${{ matrix.target }}
cargo clippy --release --all-features --target ${{ matrix.target }}
- name: Tests (Debug)
run: |
cargo test --target ${{ matrix.target }}
cargo test --all-features --target ${{ matrix.target }}
- name: Tests (Release)
run: |
cargo test --release --target ${{ matrix.target }}
cargo test --release --all-features --target ${{ matrix.target }}
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.10.0](https://github.com/Blobfolio/argyle/releases/tag/v0.10.0) - 2024-10-17

This release finishes the work of the last one. The streaming version of `Argue` is now stable and all there is; the old methods and structs have been removed.

Check out the [docs](https://docs.rs/argyle/latest/argyle/) to see how it all works!



## [0.9.0](https://github.com/Blobfolio/argyle/releases/tag/v0.9.0) - 2024-10-14

This release introduces a brand new streaming version of the argument parser `Argue`. It is simpler and cleaner, but works completely differently than the original.
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.9.0
Generated: 2024-10-14 21:16:53 UTC
Version: 0.10.0
Generated: 2024-10-17 19:06:19 UTC

This package has no dependencies.
10 changes: 1 addition & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "argyle"
version = "0.9.0"
version = "0.10.0"
authors = ["Blobfolio, LLC. <[email protected]>"]
edition = "2021"
rust-version = "1.81"
Expand All @@ -21,18 +21,10 @@ exclude = [
[package.metadata.docs.rs]
rustc-args = ["--cfg", "docsrs"]
rustdoc-args = ["--cfg", "docsrs"]
features = [ "dynamic-help" ]
default-target = "x86_64-unknown-linux-gnu"
targets = [ "x86_64-unknown-linux-gnu", "x86_64-apple-darwin" ]

[package.metadata.bashman]
name = "Argyle"
bash-dir = "./"
man-dir = "./"
credits-dir = "./"

[features]
default = []

# Enables ArgyleError::WantsDynamicHelp variant.
dynamic-help = []
83 changes: 42 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

This crate provides a simple streaming CLI argument parser/iterator called `Argue`, offering a middle ground between the standard library's barebones `std::env::args_os` helper and full-service crates like [clap](https://crates.io/crates/clap).

`Argue` performs some basic normalization — it handles string conversion in a non-panicking way, recognizes shorthand value assignments like `-kval`, `-k=val`, `--key=val`, and handles end-of-command (`--`) arguments — and will help identify any special subcommands and/or keys/values expected by your app.
`Argue` performs some basic normalization — it handles string conversion in a non-panicking way, recognizes shorthand value assignments like `-kval`, `-k=val`, `--key=val`, and handles end-of-command (`--`) arguments — and will help identify any special keys/values expected by your app.

The subsequent validation and handling, however, are left _entirely up to you_. Loop, match, and proceed however you see fit.

Expand All @@ -33,10 +33,10 @@ argyle = "0.9.*"

A general setup might look something like the following.

Refer to the documentation for `Argue` for more information, caveats, etc.
Refer to the documentation for `Argue`, `KeyWord`, and `Argument` for more information, caveats, etc.

```rust
use argyle::stream::Argument;
use argyle::{Argument, KeyWord};
use std::path::PathBuf;

#[derive(Debug, Clone, Default)]
Expand All @@ -47,46 +47,47 @@ struct Settings {
paths: Vec<PathBuf>,
}

fn main() {
let args = argyle::stream::args()
.with_keys([
("-h", false), // Boolean flag.
("--help", false), // Boolean flag.
("--threads", true), // Expects a value.
("--verbose", false), // Boolean flag.
])
.unwrap(); // An error will only occur if a
// duplicate or invalid key is declared.

// Loop and handle!
let mut settings = Settings::default();
for arg in args {
match arg {
Argument::Key("-h" | "--help") => {
println!("Help Screen Goes Here.");
return;
},
Argument::Key("--verbose") => {
settings.verbose = true;
},
Argument::KeyWithValue("--threads", threads) => {
settings.threads = threads.parse().expect("Threads must be a number!");
},
// Something else… maybe you want to assume it's a path?
Argument::Other(v) => {
settings.paths.push(PathBuf::from(v));
},
// Also something else, but not String-able. Paths don't care,
// though, so for this example maybe you just keep it?
Argument::InvalidUtf8(v) => {
settings.paths.push(PathBuf::from(v));
},
_ => {}, // Not relevant here.
}
let args = argyle::args()
.with_keywords([
KeyWord::key("-h").unwrap(), // Boolean flag (short).
KeyWord::key("--help").unwrap(), // Boolean flag (long).
KeyWord::key_with_value("-j").unwrap(), // Expects a value.
KeyWord::key_with_value("--threads").unwrap(),
]);

// Loop and handle!
let mut settings = Settings::default();
for arg in args {
match arg {
// Help flag match.
Argument::Key("-h" | "--help") => {
println!("Help Screen Goes Here.");
return;
},

// Thread option match.
Argument::KeyWithValue("-j" | "--threads", value) => {
settings.threads = value.parse()
.expect("Maximum threads must be a number!");
},

// Something else.
Argument::Other(v) => {
settings.paths.push(PathBuf::from(v));
},

// Also something else, but not String-able. PathBuf doesn't care
// about UTF-8, though, so it might be fine!
Argument::InvalidUtf8(v) => {
settings.paths.push(PathBuf::from(v));
},

// Nothing else is relevant here.
_ => {},
}

// Do something with those settings…
}

// Now that you're set up, do stuff…
```


Expand Down
2 changes: 1 addition & 1 deletion examples/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This example parses any arbitrary arguments fed to it and displays the results.
*/

fn main() {
for arg in argyle::stream::args() {
for arg in argyle::args() {
println!("\x1b[2m-----\x1b[0m\n{arg:?}");
}
println!("\x1b[2m-----\x1b[0m");
Expand Down
16 changes: 2 additions & 14 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,8 @@ doc_dir := justfile_directory() + "/doc"
# Clippy.
@clippy:
clear
cargo clippy \
--all-features \
--target-dir "{{ cargo_dir }}"
cargo clippy \
--release \
--all-features \
--target-dir "{{ cargo_dir }}"


Expand All @@ -58,7 +54,6 @@ doc_dir := justfile_directory() + "/doc"
clear
cargo run \
-q \
--all-features \
--release \
--example "debug" \
--target-dir "{{ cargo_dir }}" \
Expand All @@ -67,16 +62,9 @@ doc_dir := justfile_directory() + "/doc"

# Build Docs.
@doc:
# Make sure nightly is installed; this version generates better docs.
env RUSTUP_PERMIT_COPY_RENAME=true rustup install nightly

# Make the docs.
cargo +nightly rustdoc \
cargo rustdoc \
--release \
--all-features \
--target-dir "{{ cargo_dir }}" \
-- \
--cfg docsrs
--target-dir "{{ cargo_dir }}"

# Move the docs and clean up ownership.
[ ! -d "{{ doc_dir }}" ] || rm -rf "{{ doc_dir }}"
Expand Down
Loading

0 comments on commit 7ba675f

Please sign in to comment.