forked from extern/nushell
Explicitly indicate duplicate flags (#11226)
# Description This PR adds an explicit indication for duplicate flags, which helps with debugging. # User-Facing Changes N/A # Tests + Formatting - [x] `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - [x] `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to check that you're using the standard code style - [x] `cargo test --workspace` to check that all tests pass (on Windows make sure to [enable developer mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging)) - [x] `cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"` to run the tests for the standard library # After Submitting N/A
This commit is contained in:
parent
67eec92e76
commit
f8c82588b6
@ -469,7 +469,8 @@ impl Signature {
|
|||||||
let s = short.map(|c| {
|
let s = short.map(|c| {
|
||||||
debug_assert!(
|
debug_assert!(
|
||||||
!self.get_shorts().contains(&c),
|
!self.get_shorts().contains(&c),
|
||||||
"There may be duplicate short flags, such as -h"
|
"There may be duplicate short flags for '-{}'",
|
||||||
|
c
|
||||||
);
|
);
|
||||||
c
|
c
|
||||||
});
|
});
|
||||||
@ -478,7 +479,8 @@ impl Signature {
|
|||||||
let name: String = name.into();
|
let name: String = name.into();
|
||||||
debug_assert!(
|
debug_assert!(
|
||||||
!self.get_names().contains(&name.as_str()),
|
!self.get_names().contains(&name.as_str()),
|
||||||
"There may be duplicate name flags, such as --help"
|
"There may be duplicate name flags for '--{}'",
|
||||||
|
name
|
||||||
);
|
);
|
||||||
name
|
name
|
||||||
};
|
};
|
||||||
|
@ -96,7 +96,7 @@ fn test_signature_chained() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic(expected = "There may be duplicate short flags, such as -h")]
|
#[should_panic(expected = "There may be duplicate short flags for '-n'")]
|
||||||
fn test_signature_same_short() {
|
fn test_signature_same_short() {
|
||||||
// Creating signature with same short name should panic
|
// Creating signature with same short name should panic
|
||||||
Signature::new("new_signature")
|
Signature::new("new_signature")
|
||||||
@ -110,7 +110,7 @@ fn test_signature_same_short() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic(expected = "There may be duplicate name flags, such as --help")]
|
#[should_panic(expected = "There may be duplicate name flags for '--name'")]
|
||||||
fn test_signature_same_name() {
|
fn test_signature_same_name() {
|
||||||
// Creating signature with same short name should panic
|
// Creating signature with same short name should panic
|
||||||
Signature::new("new-signature")
|
Signature::new("new-signature")
|
||||||
|
Loading…
Reference in New Issue
Block a user