mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-11-29 14:00:31 +08:00
cli: fix ambiguity between mutually exclusive args
There are some cases where it is just safe to skip the `--x` flag because it is already set to true by default, and other cases where we need to use an option value. Also, I may miss some team code conventions regarding the PartialEq and Eq macros to enable the quality on the `Comment` type! Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
This commit is contained in:
@@ -98,20 +98,25 @@ impl Args for Options {
|
||||
|
||||
// Options.
|
||||
Long("message") | Short('m') => {
|
||||
let txt: String = parser.value()?.to_string_lossy().into();
|
||||
message.append(&txt);
|
||||
if message != Comment::Blank {
|
||||
// We skip this code when `no-message` is specified.
|
||||
let txt: String = parser.value()?.to_string_lossy().into();
|
||||
message.append(&txt);
|
||||
}
|
||||
}
|
||||
Long("no-message") => {
|
||||
message = Comment::Blank;
|
||||
}
|
||||
Long("sync") => {
|
||||
sync = true;
|
||||
// By default it is already true, so
|
||||
// the only case where this is false,
|
||||
// is the case where `no-sync` is specified.
|
||||
}
|
||||
Long("no-sync") => {
|
||||
sync = false;
|
||||
}
|
||||
Long("push") => {
|
||||
push = true;
|
||||
// Skip for the same reason as `sync`.
|
||||
}
|
||||
Long("no-push") => {
|
||||
push = false;
|
||||
|
||||
Reference in New Issue
Block a user