mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-11-21 18:40:39 +08:00
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:
@@ -79,7 +79,7 @@ impl Args for Options {
|
||||
Long("verbose") | Short('v') => {
|
||||
verbose = true;
|
||||
}
|
||||
Long("seed") if matches!(mode, SyncMode::Fetch) => {
|
||||
Long("seed") => {
|
||||
let val = parser.value()?;
|
||||
let val = term::args::nid(&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((
|
||||
Options {
|
||||
rid,
|
||||
|
||||
Reference in New Issue
Block a user