From c7b6549f6a49e63b6af14cb9fc67fc742dc819b2 Mon Sep 17 00:00:00 2001 From: Remo Senekowitsch Date: Tue, 3 Dec 2024 20:30:36 +0100 Subject: [PATCH] completion: teach absorb and bookmark move about revisions These were simply forgotten in dd6479f104818513906b346e8909d76e956db038 --- cli/src/commands/absorb.rs | 14 ++++++++++++-- cli/src/commands/bookmark/move.rs | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/cli/src/commands/absorb.rs b/cli/src/commands/absorb.rs index 97446d24b9..2162a53a2d 100644 --- a/cli/src/commands/absorb.rs +++ b/cli/src/commands/absorb.rs @@ -19,6 +19,7 @@ use std::ops::Range; use std::rc::Rc; use bstr::BString; +use clap_complete::ArgValueCandidates; use futures::StreamExt as _; use itertools::Itertools as _; use jj_lib::annotate::get_annotation_with_file_content; @@ -49,6 +50,7 @@ use tracing::instrument; use crate::cli_util::CommandHelper; use crate::cli_util::RevisionArg; use crate::command_error::CommandError; +use crate::complete; use crate::ui::Ui; /// Move changes from a revision into the stack of mutable revisions @@ -62,12 +64,20 @@ use crate::ui::Ui; #[derive(clap::Args, Clone, Debug)] pub(crate) struct AbsorbArgs { /// Source revision to absorb from - #[arg(long, short, default_value = "@")] + #[arg( + long, short, + default_value = "@", + add = ArgValueCandidates::new(complete::mutable_revisions), + )] from: RevisionArg, /// Destination revisions to absorb into /// /// Only ancestors of the source revision will be considered. - #[arg(long, short = 't', visible_alias = "to", default_value = "mutable()")] + #[arg( + long, short = 't', visible_alias = "to", + default_value = "mutable()", + add = ArgValueCandidates::new(complete::mutable_revisions), + )] into: Vec, /// Move only changes to these paths (instead of all paths) #[arg(value_hint = clap::ValueHint::AnyPath)] diff --git a/cli/src/commands/bookmark/move.rs b/cli/src/commands/bookmark/move.rs index 4b458e8f6c..e12b2ea271 100644 --- a/cli/src/commands/bookmark/move.rs +++ b/cli/src/commands/bookmark/move.rs @@ -46,13 +46,23 @@ pub struct BookmarkMoveArgs { // We intentionally do not support the short `-f` for `--from` since it // could be confused with a shorthand for `--force`, and people might not // realize they need `-B`/`--allow-backwards` instead. - #[arg(long, group = "source", value_name = "REVISIONS")] + #[arg( + long, + group = "source", + value_name = "REVISIONS", + add = ArgValueCandidates::new(complete::all_revisions), + )] from: Vec, /// Move bookmarks to this revision // We intentionally do not support the short `-t` for `--to` since we don't // support `-f` for `--from`. - #[arg(long, default_value = "@", value_name = "REVISION")] + #[arg( + long, + default_value = "@", + value_name = "REVISION", + add = ArgValueCandidates::new(complete::all_revisions), + )] to: RevisionArg, /// Allow moving bookmarks backwards or sideways