Skip to content

Commit

Permalink
completion: add completion for jj bookmark {create,set} --revision
Browse files Browse the repository at this point in the history
  • Loading branch information
bnjmnt4n committed Dec 12, 2024
1 parent 0de3691 commit 2504703
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 7 additions & 1 deletion cli/src/commands/bookmark/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand All @@ -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<RevisionArg>,

/// The bookmarks to create
Expand Down
6 changes: 5 additions & 1 deletion cli/src/commands/bookmark/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<RevisionArg>,

/// Allow moving the bookmark backwards or sideways
Expand Down

0 comments on commit 2504703

Please sign in to comment.