Repository: pacak/bpaf
Pull request #126 (2022-11-19 23:51:40)

Release 0.7.4
Mostly bugfixes


Patch:
diff --git a/Cargo.toml b/Cargo.toml
index c6a823d..1a9563b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "bpaf"
-version = "0.7.3"
+version = "0.7.4"
 edition = "2021"
 categories = ["command-line-interface"]
 description = "A simple Command Line Argument Parser with parser combinators"
@@ -14,7 +14,7 @@ exclude = [".github/workflows", "tarp.sh"]
 
 
 [dependencies]
-bpaf_derive = { path = "./bpaf_derive", version = "=0.3.2", optional = true }
+bpaf_derive = { path = "./bpaf_derive", version = "=0.3.3", optional = true }
 owo-colors = { version = "3.5.0", features = ["supports-colors"], optional = true }
 
 [dev-dependencies]
diff --git a/Changelog.md b/Changelog.md
index 77763d7..c99b00d 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -1,5 +1,9 @@
 # Change Log
 
+## bpaf [0.7.4], bpaf_derive [0.3.3] - 2022-11-19
+- bpaf_derive: improve error message
+- bpaf: bugfix for bash static shell completion
+
 ## bpaf [0.7.3] - 2022-11-14
 - `try_run`
    thanks to @ysndr
diff --git a/README.md b/README.md
index 110d50f..875d208 100644
--- a/README.md
+++ b/README.md
@@ -372,21 +372,21 @@ Usage --user <ARG>
 	
 
 
- [__cargo_doc2readme_dependencies_info]: ggGkYW0AYXSEG52uRQSwBdezG6GWW8ODAbr5G6KRmT_WpUB5G9hPmBcUiIp6YXKEG-IPQtuM4VUFG47iETJwkSENG_GD7ukhn-KMG38J41C6yQn3YWSBgmRicGFmZTAuNy4z
- [__link0]: https://docs.rs/bpaf/0.7.3/bpaf/?search=_derive_tutorial
- [__link1]: https://docs.rs/bpaf/0.7.3/bpaf/?search=_combinatoric_tutorial
- [__link10]: https://docs.rs/bpaf/0.7.3/bpaf/?search=parsers::NamedArg::switch
- [__link11]: https://docs.rs/bpaf/0.7.3/bpaf/?search=parsers::NamedArg::argument
- [__link12]: https://docs.rs/bpaf/0.7.3/bpaf/?search=params::positional
- [__link13]: https://docs.rs/bpaf/0.7.3/bpaf/?search=parsers::NamedArg::argument
- [__link14]: https://docs.rs/bpaf/0.7.3/bpaf/?search=params::positional
- [__link15]: https://docs.rs/bpaf/0.7.3/bpaf/?search=bpaf::Parser::complete
- [__link17]: https://docs.rs/bpaf/0.7.3/bpaf/?search=info::OptionParser::run_inner
- [__link2]: https://docs.rs/bpaf/0.7.3/bpaf/?search=_unusual
- [__link3]: https://docs.rs/bpaf/0.7.3/bpaf/?search=_applicative
- [__link4]: https://docs.rs/bpaf/0.7.3/bpaf/?search=batteries
+ [__cargo_doc2readme_dependencies_info]: ggGkYW0AYXSEG52uRQSwBdezG6GWW8ODAbr5G6KRmT_WpUB5G9hPmBcUiIp6YXKEG-IPQtuM4VUFG47iETJwkSENG_GD7ukhn-KMG38J41C6yQn3YWSBgmRicGFmZTAuNy40
+ [__link0]: https://docs.rs/bpaf/0.7.4/bpaf/?search=_derive_tutorial
+ [__link1]: https://docs.rs/bpaf/0.7.4/bpaf/?search=_combinatoric_tutorial
+ [__link10]: https://docs.rs/bpaf/0.7.4/bpaf/?search=parsers::NamedArg::switch
+ [__link11]: https://docs.rs/bpaf/0.7.4/bpaf/?search=parsers::NamedArg::argument
+ [__link12]: https://docs.rs/bpaf/0.7.4/bpaf/?search=params::positional
+ [__link13]: https://docs.rs/bpaf/0.7.4/bpaf/?search=parsers::NamedArg::argument
+ [__link14]: https://docs.rs/bpaf/0.7.4/bpaf/?search=params::positional
+ [__link15]: https://docs.rs/bpaf/0.7.4/bpaf/?search=bpaf::Parser::complete
+ [__link17]: https://docs.rs/bpaf/0.7.4/bpaf/?search=info::OptionParser::run_inner
+ [__link2]: https://docs.rs/bpaf/0.7.4/bpaf/?search=_unusual
+ [__link3]: https://docs.rs/bpaf/0.7.4/bpaf/?search=_applicative
+ [__link4]: https://docs.rs/bpaf/0.7.4/bpaf/?search=batteries
  [__link5]: https://github.com/pacak/bpaf/discussions/categories/q-a
- [__link6]: https://docs.rs/bpaf/0.7.3/bpaf/?search=_derive_tutorial
- [__link7]: https://docs.rs/bpaf/0.7.3/bpaf/?search=_combinatoric_tutorial
- [__link8]: https://docs.rs/bpaf/0.7.3/bpaf/?search=_applicative
- [__link9]: https://docs.rs/bpaf/0.7.3/bpaf/?search=bpaf::Parser::fallback
+ [__link6]: https://docs.rs/bpaf/0.7.4/bpaf/?search=_derive_tutorial
+ [__link7]: https://docs.rs/bpaf/0.7.4/bpaf/?search=_combinatoric_tutorial
+ [__link8]: https://docs.rs/bpaf/0.7.4/bpaf/?search=_applicative
+ [__link9]: https://docs.rs/bpaf/0.7.4/bpaf/?search=bpaf::Parser::fallback
diff --git a/bpaf_cauwugo/Cargo.toml b/bpaf_cauwugo/Cargo.toml
index 2d361fb..edadbcf 100644
--- a/bpaf_cauwugo/Cargo.toml
+++ b/bpaf_cauwugo/Cargo.toml
@@ -12,7 +12,7 @@ description = "A cargo frontend with dynamic completion"
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
 [dependencies]
-bpaf = { version = "0.7.3", path = "../", features = ["derive", "autocomplete"] }
+bpaf = { version = "0.7.4", path = "../", features = ["derive", "autocomplete"] }
 cargo_metadata = "0.15.0"
 once_cell = "1.13.1"
 
diff --git a/bpaf_derive/Cargo.toml b/bpaf_derive/Cargo.toml
index 5c9dac6..93dd012 100644
--- a/bpaf_derive/Cargo.toml
+++ b/bpaf_derive/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "bpaf_derive"
-version = "0.3.2"
+version = "0.3.3"
 edition = "2018"
 categories = ["command-line-interface"]
 description = "Derive macros for bpaf Command Line Argument Parser"
diff --git a/bpaf_derive/src/field/named_field.rs b/bpaf_derive/src/field/named_field.rs
index b2f2056..090de16 100644
--- a/bpaf_derive/src/field/named_field.rs
+++ b/bpaf_derive/src/field/named_field.rs
@@ -32,8 +32,10 @@ fn check_stage(prev: &mut usize, new: usize, keyword: &Ident) -> Result<()> {
         return Err(syn::Error::new(
             keyword.span(),
             format!(
-                "{} is a {} can't follow previous stage ({})",
-                keyword, stages[new], stages[*prev]
+                "keyword `{}` is at stage `{}` can't follow previous stage ({})",
+                keyword,
+                stages[new - 1],
+                stages[*prev - 1]
             ),
         ));
     }
diff --git a/src/complete_run.rs b/src/complete_run.rs
index a1a9d31..711a869 100644
--- a/src/complete_run.rs
+++ b/src/complete_run.rs
@@ -63,8 +63,8 @@ _bpaf_dynamic_completion()
     IFS=$'\\n' BPAF_REPLY=($( \"$1\" --bpaf-complete-rev={rev} \"${{COMP_WORDS[@]:1}}\" ))
     for line in \"${{BPAF_REPLY[@]}}\" ; do
         IFS=$'\\t' parts=( $line )
-        declare -A table;
         if [[ \"${{parts[0]}}\" == \"literal\" ]] ; then
+            declare -A table;
             kw=\"\"
             for part in \"${{parts[@]}}\" ; do
                 if [ -z \"$kw\" ] ; then
@@ -80,7 +80,7 @@ _bpaf_dynamic_completion()
                 COMPREPLY+=(\"${{table[\"literal\"]}}\")
             fi
         elif [[ \"${{parts[0]}}\" == \"bash\" ]] ; then
-            ${{parts[1]}} \"${{parts[@]:2}}\"
+            eval ${{parts[1]}}
         else
             COMPREPLY+=(\"${{parts[0]}}\")
         fi


Test patch:
diff --git a/bpaf_derive/src/field_tests.rs b/bpaf_derive/src/field_tests.rs
index 2f5e70a..1cd6081 100644
--- a/bpaf_derive/src/field_tests.rs
+++ b/bpaf_derive/src/field_tests.rs
@@ -625,3 +625,14 @@ fn argument_with_manual_parse() {
     };
     assert_eq!(input.to_token_stream().to_string(), output.to_string());
 }
+
+#[test]
+fn optional_external_strange() {
+    let input: TokenStream = quote! {
+        #[bpaf(optional, external(seed))]
+        number: u32
+    };
+    let msg =
+        "keyword `external` is at stage `external` can't follow previous stage (postprocessing)";
+    field_trans_fail(input, msg);
+}