cli: Fix partial matching for the --seed flag
This commit addresses the inconsistent parsing of the command by fixing the
partial matching behavior for the `--seed` flag. Previously, specifying
the seed value resulted in an invalid option error, as shown in the example below:
```
➜ ~ rad sync --seed z6MksmpU5b1dS7oaqF2bHXhQi1DWy2hB7Mh9CuN7y1DN6QSz
✗ Error: rad sync: invalid option '--seed'
```
With this fix, there are no restrictions on when the seed can be specified.
In a future change, we plan to implement a custom error message when a
match case does not meet specific requirements, such as `rad --fetch --announce`,
which will return a more informative error message. However, this
enhancement is left for a derived solution.
```
➜ ~ rad sync --fetch --announce
✗ Error: rad sync: invalid option '--announce'
```
Fixes: d6cebf613f
Suggested-by: Slack Coder
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
This commit is contained in:
parent
f418b5268c
commit
f91ef2963e
|
|
@ -79,7 +79,7 @@ impl Args for Options {
|
||||||
Long("verbose") | Short('v') => {
|
Long("verbose") | Short('v') => {
|
||||||
verbose = true;
|
verbose = true;
|
||||||
}
|
}
|
||||||
Long("seed") if matches!(mode, SyncMode::Fetch) => {
|
Long("seed") => {
|
||||||
let val = parser.value()?;
|
let val = parser.value()?;
|
||||||
let val = term::args::nid(&val)?;
|
let val = term::args::nid(&val)?;
|
||||||
seed = Some(val);
|
seed = Some(val);
|
||||||
|
|
@ -108,6 +108,10 @@ impl Args for Options {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if seed.is_some() && mode != SyncMode::Fetch {
|
||||||
|
anyhow::bail!("`--seed` must be used with `--fetch`");
|
||||||
|
}
|
||||||
|
|
||||||
Ok((
|
Ok((
|
||||||
Options {
|
Options {
|
||||||
rid,
|
rid,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue