From 33af658e93797e3655c5a6037f54919770ea8b60 Mon Sep 17 00:00:00 2001 From: a dinosaur Date: Mon, 17 Nov 2025 21:17:32 +1100 Subject: [PATCH 1/6] Add homepage (cherry picked from commit 23b6402db6614992d13e012bcd317ba5e1887325) --- Cargo.toml | 1 + jaarg/Cargo.toml | 1 + 2 files changed, 2 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 233335d..6c9e7f6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ license = "MIT OR Apache-2.0" edition = "2021" description = "It can parse your arguments you should use it it's called jaarg" repository = "https://github.com/gay-pizza/jaarg" +homepage = "https://gay.pizza/" authors = ["a dinosaur", "Gay Pizza Specifications"] [profile.release] diff --git a/jaarg/Cargo.toml b/jaarg/Cargo.toml index 1905207..868dfea 100644 --- a/jaarg/Cargo.toml +++ b/jaarg/Cargo.toml @@ -4,6 +4,7 @@ version.workspace = true license.workspace = true edition.workspace = true description.workspace = true +homepage.workspace = true repository.workspace = true authors.workspace = true From 8f6f1827ce6cd37eabdb5ee30fd86cecb9389f20 Mon Sep 17 00:00:00 2001 From: a dinosaur Date: Mon, 17 Nov 2025 21:27:07 +1100 Subject: [PATCH 2/6] Add simple argparse test for values (cherry picked from commit 14028ed2c87dbfac09c82f2c8529bce5e730b657) --- jaarg/src/argparse.rs | 46 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/jaarg/src/argparse.rs b/jaarg/src/argparse.rs index de6a7ff..a1a68db 100644 --- a/jaarg/src/argparse.rs +++ b/jaarg/src/argparse.rs @@ -242,3 +242,49 @@ impl Opts { } } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_parse() { + extern crate alloc; + use alloc::string::String; + + enum ArgID { One, Two, Three, Four, Five } + const OPTIONS: Opts = Opts::new(&[ + Opt::positional(ArgID::One, "one"), + Opt::flag(ArgID::Two, &["--two"]), + Opt::value(ArgID::Three, &["--three"], "value"), + Opt::value(ArgID::Four, &["--four"], "value"), + Opt::value(ArgID::Five, &["--five"], "value"), + ]); + const ARGUMENTS: &[&str] = &["one", "--two", "--three=three", "--five=", "--four", "four"]; + + //TODO: currently needs alloc to deal with arguments not being able to escape handler + let mut one: Option = None; + let mut two = false; + let mut three: Option = None; + let mut four: Option = None; + let mut five: Option = None; + assert!(matches!(OPTIONS.parse("", ARGUMENTS.iter(), |_program_name, id, _opt, _name, arg| { + match id { + ArgID::One => { one = Some(arg.into()); } + ArgID::Two => { two = true; } + ArgID::Three => { three = Some(arg.into()); } + ArgID::Four => { four = Some(arg.into()); } + ArgID::Five => { five = Some(arg.into()); } + } + Ok(ParseControl::Continue) + }, |_, error| { + panic!("unreachable: {error:?}"); + }), ParseResult::ContinueSuccess)); + + assert_eq!(one, Some("one".into())); + assert!(two); + assert_eq!(three, Some("three".into())); + assert_eq!(four, Some("four".into())); + assert_eq!(five, Some("".into())); + } +} From 7165bb98411e0273f76a8c116441292439c3afa9 Mon Sep 17 00:00:00 2001 From: a dinosaur Date: Mon, 17 Nov 2025 21:31:15 +1100 Subject: [PATCH 3/6] Rename test modules for previously included files. (cherry picked from commit 75e2bde5fb33f971c743d0791475e590e31a10eb) --- jaarg/src/option.rs | 2 +- jaarg/src/options.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jaarg/src/option.rs b/jaarg/src/option.rs index a529c27..5724e39 100644 --- a/jaarg/src/option.rs +++ b/jaarg/src/option.rs @@ -241,7 +241,7 @@ impl core::ops::BitOr for OptFlag { } #[cfg(test)] -mod opt_tests { +mod tests { use super::*; #[test] diff --git a/jaarg/src/options.rs b/jaarg/src/options.rs index a6559cd..666842b 100644 --- a/jaarg/src/options.rs +++ b/jaarg/src/options.rs @@ -79,7 +79,7 @@ impl Opts { #[cfg(test)] -mod opts_tests { +mod tests { use super::*; #[test] From 20f5a0bf1024dcbfa6c7fdbc539251c044f9a579 Mon Sep 17 00:00:00 2001 From: a dinosaur Date: Wed, 26 Nov 2025 15:12:49 +1100 Subject: [PATCH 4/6] Backport positional argument handler fix. --- README.md | 1 + jaarg/src/argparse.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2aff3aa..441d01e 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ println!("{file:?} -> {out:?} (number: {number:?})", ### Changelog ### main: + * Fixed coerced `ArgumentError` not being rewritten for positional arguments. * Moved top level includes to `pub use`. v0.2.1: diff --git a/jaarg/src/argparse.rs b/jaarg/src/argparse.rs index a1a68db..1342d45 100644 --- a/jaarg/src/argparse.rs +++ b/jaarg/src/argparse.rs @@ -232,7 +232,7 @@ impl Opts { // Find the next positional argument for (i, option) in self.options[state.positional_index..].iter().enumerate() { if matches!(option.r#type, OptType::Positional) { - handler(program_name, &option.id, option, option.first_name(), token)?; + call_handler(option, option.first_name(), token)?; state.positional_index += i + 1; return Ok(ParseControl::Continue); } From 8d9e8aea8919586e549326d6676e253e8d1a5c66 Mon Sep 17 00:00:00 2001 From: a dinosaur Date: Wed, 26 Nov 2025 15:26:07 +1100 Subject: [PATCH 5/6] Cargo stinky aaaa --- README.md | 1 + jaarg/LICENSE.Apache-2.0 | 1 + jaarg/LICENSE.MIT | 1 + jaarg/README.md | 1 + 4 files changed, 4 insertions(+) create mode 120000 jaarg/LICENSE.Apache-2.0 create mode 120000 jaarg/LICENSE.MIT create mode 120000 jaarg/README.md diff --git a/README.md b/README.md index 441d01e..1b78ba6 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ println!("{file:?} -> {out:?} (number: {number:?})", main: * Fixed coerced `ArgumentError` not being rewritten for positional arguments. * Moved top level includes to `pub use`. + * Hopefully work around licence & read me texts not being included in crate. v0.2.1: * Fixed licence field in `Cargo.toml`. diff --git a/jaarg/LICENSE.Apache-2.0 b/jaarg/LICENSE.Apache-2.0 new file mode 120000 index 0000000..d4306cc --- /dev/null +++ b/jaarg/LICENSE.Apache-2.0 @@ -0,0 +1 @@ +../LICENSE.Apache-2.0 \ No newline at end of file diff --git a/jaarg/LICENSE.MIT b/jaarg/LICENSE.MIT new file mode 120000 index 0000000..6b8772d --- /dev/null +++ b/jaarg/LICENSE.MIT @@ -0,0 +1 @@ +../LICENSE.MIT \ No newline at end of file diff --git a/jaarg/README.md b/jaarg/README.md new file mode 120000 index 0000000..32d46ee --- /dev/null +++ b/jaarg/README.md @@ -0,0 +1 @@ +../README.md \ No newline at end of file From 75fc27bc589d14f9aa3614a8253b7b938885b7b4 Mon Sep 17 00:00:00 2001 From: a dinosaur Date: Wed, 26 Nov 2025 15:30:43 +1100 Subject: [PATCH 6/6] Release 0.2.2 --- Cargo.toml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6c9e7f6..c0211fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ members = ["jaarg-nostd"] resolver = "3" [workspace.package] -version = "0.2.1" +version = "0.2.2" license = "MIT OR Apache-2.0" edition = "2021" description = "It can parse your arguments you should use it it's called jaarg" diff --git a/README.md b/README.md index 1b78ba6..83c6034 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ println!("{file:?} -> {out:?} (number: {number:?})", ### Changelog ### -main: +v0.2.2: * Fixed coerced `ArgumentError` not being rewritten for positional arguments. * Moved top level includes to `pub use`. * Hopefully work around licence & read me texts not being included in crate.