From 2504703b0dbbb9bd9113e4f65127bdbd702faa72 Mon Sep 17 00:00:00 2001 From: Benjamin Tan Date: Wed, 11 Dec 2024 15:08:32 +0800 Subject: [PATCH] completion: add completion for `jj bookmark {create,set} --revision` --- cli/src/commands/bookmark/create.rs | 8 +++++++- cli/src/commands/bookmark/set.rs | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cli/src/commands/bookmark/create.rs b/cli/src/commands/bookmark/create.rs index ec1d7100ef..bcf41c6cdd 100644 --- a/cli/src/commands/bookmark/create.rs +++ b/cli/src/commands/bookmark/create.rs @@ -13,6 +13,7 @@ // limitations under the License. use clap::builder::NonEmptyStringValueParser; +use clap_complete::ArgValueCandidates; use jj_lib::object_id::ObjectId as _; use jj_lib::op_store::RefTarget; @@ -21,6 +22,7 @@ use crate::cli_util::CommandHelper; use crate::cli_util::RevisionArg; use crate::command_error::user_error_with_hint; use crate::command_error::CommandError; +use crate::complete; use crate::ui::Ui; /// Create a new bookmark @@ -30,7 +32,11 @@ pub struct BookmarkCreateArgs { // // The `--to` alias exists for making it easier for the user to switch // between `bookmark create`, `bookmark move`, and `bookmark set`. - #[arg(long, short, visible_alias = "to")] + #[arg( + long, short, + visible_alias = "to", + add = ArgValueCandidates::new(complete::all_revisions), + )] revision: Option, /// The bookmarks to create diff --git a/cli/src/commands/bookmark/set.rs b/cli/src/commands/bookmark/set.rs index f0e8951fc1..0922f9df47 100644 --- a/cli/src/commands/bookmark/set.rs +++ b/cli/src/commands/bookmark/set.rs @@ -30,7 +30,11 @@ use crate::ui::Ui; #[derive(clap::Args, Clone, Debug)] pub struct BookmarkSetArgs { /// The bookmark's target revision - #[arg(long, short, visible_alias = "to")] + #[arg( + long, short, + visible_alias = "to", + add = ArgValueCandidates::new(complete::all_revisions), + )] revision: Option, /// Allow moving the bookmark backwards or sideways