Skip to content

Commit

Permalink
Improve error message for invalid long names
Browse files Browse the repository at this point in the history
  • Loading branch information
KateMorley authored and sadmac7000 committed Oct 22, 2023
1 parent c2b8549 commit 3d2e6f6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions argh/tests/ui/bad-long-names/bad-long-names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ struct Cmd {
/// non-ascii
привет: bool,
#[argh(switch)]
/// uppercase
/// invalid character
XMLHTTPRequest: bool,
#[argh(switch, long = "not really")]
#[argh(switch, long = "invalid_character")]
/// bad attr
ok: bool,
}
Expand Down
8 changes: 4 additions & 4 deletions argh/tests/ui/bad-long-names/bad-long-names.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ error: Long names must be ASCII
6 | привет: bool,
| ^^^^^^

error: Long names must be lowercase
error: Long names may only contain lowercase letters, digits, and dashes
--> tests/ui/bad-long-names/bad-long-names.rs:9:5
|
9 | XMLHTTPRequest: bool,
| ^^^^^^^^^^^^^^

error: Long names must be lowercase
error: Long names may only contain lowercase letters, digits, and dashes
--> tests/ui/bad-long-names/bad-long-names.rs:10:27
|
10 | #[argh(switch, long = "not really")]
| ^^^^^^^^^^^^
10 | #[argh(switch, long = "invalid_character")]
| ^^^^^^^^^^^^^^^^^^^
2 changes: 1 addition & 1 deletion argh_derive/src/parse_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ pub(crate) fn check_long_name(errors: &Errors, spanned: &impl syn::spanned::Span
errors.err(spanned, "Long names must be ASCII");
}
if !value.chars().all(|c| c.is_lowercase() || c == '-' || c.is_ascii_digit()) {
errors.err(spanned, "Long names must be lowercase");
errors.err(spanned, "Long names may only contain lowercase letters, digits, and dashes");
}
}

Expand Down

0 comments on commit 3d2e6f6

Please sign in to comment.