Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use FILESETS/REVSETS for placeholders in command synopsis #5133

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion cli/src/commands/abandon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ use crate::ui::Ui;
#[derive(clap::Args, Clone, Debug)]
pub(crate) struct AbandonArgs {
/// The revision(s) to abandon
#[arg(default_value = "@", add = ArgValueCandidates::new(complete::mutable_revisions))]
#[arg(
default_value = "@",
value_name = "REVSETS",
add = ArgValueCandidates::new(complete::mutable_revisions)
)]
revisions: Vec<RevisionArg>,
/// Do not print every abandoned commit on a separate line
#[arg(long, short)]
Expand Down
4 changes: 3 additions & 1 deletion cli/src/commands/absorb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub(crate) struct AbsorbArgs {
#[arg(
long, short,
default_value = "@",
value_name = "REVSET",
add = ArgValueCandidates::new(complete::mutable_revisions),
)]
from: RevisionArg,
Expand All @@ -48,11 +49,12 @@ pub(crate) struct AbsorbArgs {
#[arg(
long, short = 't', visible_alias = "to",
default_value = "mutable()",
value_name = "REVSETS",
add = ArgValueCandidates::new(complete::mutable_revisions),
)]
into: Vec<RevisionArg>,
/// Move only changes to these paths (instead of all paths)
#[arg(value_hint = clap::ValueHint::AnyPath)]
#[arg(value_name = "FILESETS", value_hint = clap::ValueHint::AnyPath)]
paths: Vec<String>,
}

Expand Down
2 changes: 2 additions & 0 deletions cli/src/commands/backout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub(crate) struct BackoutArgs {
#[arg(
long, short,
default_value = "@",
value_name = "REVSETS",
add = ArgValueCandidates::new(complete::all_revisions),
)]
revisions: Vec<RevisionArg>,
Expand All @@ -40,6 +41,7 @@ pub(crate) struct BackoutArgs {
#[arg(
long, short,
default_value = "@",
value_name = "REVSETS",
add = ArgValueCandidates::new(complete::all_revisions),
)]
destination: Vec<RevisionArg>,
Expand Down
1 change: 1 addition & 0 deletions cli/src/commands/bookmark/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub struct BookmarkCreateArgs {
#[arg(
long, short,
visible_alias = "to",
value_name = "REVSET",
add = ArgValueCandidates::new(complete::all_revisions),
)]
revision: Option<RevisionArg>,
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/bookmark/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub struct BookmarkListArgs {
///
/// Note that `-r deleted_bookmark` will not work since `deleted_bookmark`
/// wouldn't have a local target.
#[arg(long, short)]
#[arg(long, short, value_name = "REVSETS")]
revisions: Option<Vec<RevisionArg>>,

/// Render each bookmark using the given template
Expand Down
4 changes: 2 additions & 2 deletions cli/src/commands/bookmark/move.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub struct BookmarkMoveArgs {
#[arg(
long,
group = "source",
value_name = "REVISIONS",
value_name = "REVSETS",
add = ArgValueCandidates::new(complete::all_revisions),
)]
from: Vec<RevisionArg>,
Expand All @@ -60,7 +60,7 @@ pub struct BookmarkMoveArgs {
#[arg(
long,
default_value = "@",
value_name = "REVISION",
value_name = "REVSET",
add = ArgValueCandidates::new(complete::all_revisions),
)]
to: RevisionArg,
Expand Down
1 change: 1 addition & 0 deletions cli/src/commands/bookmark/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub struct BookmarkSetArgs {
#[arg(
long, short,
visible_alias = "to",
value_name = "REVSET",
add = ArgValueCandidates::new(complete::all_revisions),
)]
revision: Option<RevisionArg>,
Expand Down
1 change: 1 addition & 0 deletions cli/src/commands/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub(crate) struct CommitArgs {
message_paragraphs: Vec<String>,
/// Put these paths in the first commit
#[arg(
value_name = "FILESETS",
value_hint = clap::ValueHint::AnyPath,
add = ArgValueCompleter::new(complete::modified_files),
)]
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/debug/copy_detection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use crate::ui::Ui;
#[derive(clap::Args, Clone, Debug)]
pub struct CopyDetectionArgs {
/// Show changes in this revision, compared to its parent(s)
#[arg(default_value = "@")]
#[arg(default_value = "@", value_name = "REVSET")]
revision: RevisionArg,
}

Expand Down
3 changes: 2 additions & 1 deletion cli/src/commands/debug/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ use crate::ui::Ui;
/// List the recursive entries of a tree.
#[derive(clap::Args, Clone, Debug)]
pub struct DebugTreeArgs {
#[arg(long, short = 'r')]
#[arg(long, short = 'r', value_name = "REVSET")]
revision: Option<RevisionArg>,
#[arg(long, conflicts_with = "revision")]
id: Option<String>,
#[arg(long, requires = "id")]
dir: Option<String>,
#[arg(value_name = "FILESETS")]
paths: Vec<String>,
// TODO: Add an option to include trees that are ancestors of the matched paths
}
Expand Down
6 changes: 5 additions & 1 deletion cli/src/commands/describe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ use crate::ui::Ui;
#[command(visible_aliases = &["desc"])]
pub(crate) struct DescribeArgs {
/// The revision(s) whose description to edit
#[arg(default_value = "@", add = ArgValueCandidates::new(complete::mutable_revisions))]
#[arg(
default_value = "@",
value_name = "REVSETS",
add = ArgValueCandidates::new(complete::mutable_revisions)
)]
revisions: Vec<RevisionArg>,
/// Ignored (but lets you pass `-r` for consistency with other commands)
#[arg(short = 'r', hide = true, action = clap::ArgAction::Count)]
Expand Down
24 changes: 21 additions & 3 deletions cli/src/commands/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,34 @@ pub(crate) struct DiffArgs {
/// If the revision is a merge commit, this shows changes *from* the
/// automatic merge of the contents of all of its parents *to* the contents
/// of the revision itself.
#[arg(long, short, add = ArgValueCandidates::new(complete::all_revisions))]
#[arg(
long,
short,
value_name = "REVSET",
add = ArgValueCandidates::new(complete::all_revisions)
)]
revision: Option<RevisionArg>,
/// Show changes from this revision
#[arg(long, short, conflicts_with = "revision", add = ArgValueCandidates::new(complete::all_revisions))]
#[arg(
long,
short,
conflicts_with = "revision",
value_name = "REVSET",
add = ArgValueCandidates::new(complete::all_revisions)
)]
from: Option<RevisionArg>,
/// Show changes to this revision
#[arg(long, short, conflicts_with = "revision", add = ArgValueCandidates::new(complete::all_revisions))]
#[arg(
long,
short,
conflicts_with = "revision",
value_name = "REVSET",
add = ArgValueCandidates::new(complete::all_revisions)
)]
to: Option<RevisionArg>,
/// Restrict the diff to these paths
#[arg(
value_name = "FILESETS",
value_hint = clap::ValueHint::AnyPath,
add = ArgValueCompleter::new(complete::modified_revision_or_range_files),
)]
Expand Down
9 changes: 8 additions & 1 deletion cli/src/commands/diffedit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,20 @@ pub(crate) struct DiffeditArgs {
/// The revision to touch up
///
/// Defaults to @ if neither --to nor --from are specified.
#[arg(long, short, add = ArgValueCandidates::new(complete::mutable_revisions))]
#[arg(
long,
short,
value_name = "REVSET",
add = ArgValueCandidates::new(complete::mutable_revisions)
)]
revision: Option<RevisionArg>,
/// Show changes from this revision
///
/// Defaults to @ if --to is specified.
#[arg(
long, short,
conflicts_with = "revision",
value_name = "REVSET",
add = ArgValueCandidates::new(complete::all_revisions),
)]
from: Option<RevisionArg>,
Expand All @@ -67,6 +73,7 @@ pub(crate) struct DiffeditArgs {
#[arg(
long, short,
conflicts_with = "revision",
value_name = "REVSET",
add = ArgValueCandidates::new(complete::mutable_revisions),
)]
to: Option<RevisionArg>,
Expand Down
16 changes: 13 additions & 3 deletions cli/src/commands/duplicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,21 @@ use crate::ui::Ui;
#[derive(clap::Args, Clone, Debug)]
pub(crate) struct DuplicateArgs {
/// The revision(s) to duplicate (default: @)
#[arg(value_name = "REVISIONS", add = ArgValueCandidates::new(complete::all_revisions))]
#[arg(
value_name = "REVSETS",
add = ArgValueCandidates::new(complete::all_revisions)
)]
revisions_pos: Vec<RevisionArg>,
#[arg(short = 'r', hide = true)]
#[arg(short = 'r', hide = true, value_name = "REVSETS")]
revisions_opt: Vec<RevisionArg>,
/// The revision(s) to duplicate onto (can be repeated to create a merge
/// commit)
#[arg(long, short, add = ArgValueCandidates::new(complete::all_revisions))]
#[arg(
long,
short,
value_name = "REVSETS",
add = ArgValueCandidates::new(complete::all_revisions)
)]
destination: Vec<RevisionArg>,
/// The revision(s) to insert after (can be repeated to create a merge
/// commit)
Expand All @@ -67,6 +75,7 @@ pub(crate) struct DuplicateArgs {
short = 'A',
visible_alias = "after",
conflicts_with = "destination",
value_name = "REVSETS",
add = ArgValueCandidates::new(complete::all_revisions),
)]
insert_after: Vec<RevisionArg>,
Expand All @@ -77,6 +86,7 @@ pub(crate) struct DuplicateArgs {
short = 'B',
visible_alias = "before",
conflicts_with = "destination",
value_name = "REVSETS",
add = ArgValueCandidates::new(complete::mutable_revisions)
)]
insert_before: Vec<RevisionArg>,
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use crate::ui::Ui;
#[derive(clap::Args, Clone, Debug)]
pub(crate) struct EditArgs {
/// The commit to edit
#[arg(add = ArgValueCandidates::new(complete::mutable_revisions))]
#[arg(value_name = "REVSET", add = ArgValueCandidates::new(complete::mutable_revisions))]
revision: RevisionArg,
/// Ignored (but lets you pass `-r` for consistency with other commands)
#[arg(short = 'r', hide = true)]
Expand Down
1 change: 1 addition & 0 deletions cli/src/commands/evolog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub(crate) struct EvologArgs {
#[arg(
long, short,
default_value = "@",
value_name = "REVSET",
add = ArgValueCandidates::new(complete::all_revisions),
)]
revision: RevisionArg,
Expand Down
7 changes: 6 additions & 1 deletion cli/src/commands/file/annotate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ pub(crate) struct FileAnnotateArgs {
)]
path: String,
/// an optional revision to start at
#[arg(long, short, add = ArgValueCandidates::new(complete::all_revisions))]
#[arg(
long,
short,
value_name = "REVSET",
add = ArgValueCandidates::new(complete::all_revisions)
)]
revision: Option<RevisionArg>,
}

Expand Down
2 changes: 2 additions & 0 deletions cli/src/commands/file/chmod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ pub(crate) struct FileChmodArgs {
#[arg(
long, short,
default_value = "@",
value_name = "REVSET",
add = ArgValueCandidates::new(complete::mutable_revisions),
)]
revision: RevisionArg,
/// Paths to change the executable bit for
#[arg(
required = true,
value_name = "FILESETS",
value_hint = clap::ValueHint::AnyPath,
add = ArgValueCompleter::new(complete::all_revision_files),
)]
Expand Down
3 changes: 2 additions & 1 deletion cli/src/commands/file/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ pub(crate) struct FileListArgs {
#[arg(
long, short,
default_value = "@",
value_name = "REVSET",
add = ArgValueCandidates::new(complete::all_revisions),
)]
revision: RevisionArg,
/// Only list files matching these prefixes (instead of all files)
#[arg(value_hint = clap::ValueHint::AnyPath)]
#[arg(value_name = "FILESETS", value_hint = clap::ValueHint::AnyPath)]
paths: Vec<String>,
}

Expand Down
2 changes: 2 additions & 0 deletions cli/src/commands/file/show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ pub(crate) struct FileShowArgs {
#[arg(
long, short,
default_value = "@",
value_name = "REVSET",
add = ArgValueCandidates::new(complete::all_revisions),
)]
revision: RevisionArg,
/// Paths to print
#[arg(
required = true,
value_name = "FILESETS",
value_hint = clap::ValueHint::FilePath,
add = ArgValueCompleter::new(complete::all_revision_files),
)]
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/file/track.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use crate::ui::Ui;
#[derive(clap::Args, Clone, Debug)]
pub(crate) struct FileTrackArgs {
/// Paths to track
#[arg(required = true, value_hint = clap::ValueHint::AnyPath)]
#[arg(required = true, value_name = "FILESETS", value_hint = clap::ValueHint::AnyPath)]
paths: Vec<String>,
}

Expand Down
1 change: 1 addition & 0 deletions cli/src/commands/file/untrack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub(crate) struct FileUntrackArgs {
/// colocated repos).
#[arg(
required = true,
value_name = "FILESETS",
value_hint = clap::ValueHint::AnyPath,
add = ArgValueCompleter::new(complete::all_revision_files),
)]
Expand Down
9 changes: 7 additions & 2 deletions cli/src/commands/fix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,15 @@ pub(crate) struct FixArgs {
/// Fix files in the specified revision(s) and their descendants. If no
/// revisions are specified, this defaults to the `revsets.fix` setting, or
/// `reachable(@, mutable())` if it is not set.
#[arg(long, short, add = ArgValueCandidates::new(complete::mutable_revisions))]
#[arg(
long,
short,
value_name = "REVSETS",
add = ArgValueCandidates::new(complete::mutable_revisions)
)]
source: Vec<RevisionArg>,
/// Fix only these paths
#[arg(value_hint = clap::ValueHint::AnyPath)]
#[arg(value_name = "FILESETS", value_hint = clap::ValueHint::AnyPath)]
paths: Vec<String>,
/// Fix unchanged files in addition to changed ones. If no paths are
/// specified, all files in the repo will be fixed.
Expand Down
4 changes: 2 additions & 2 deletions cli/src/commands/git/push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ pub struct GitPushArgs {
#[arg(long)]
allow_private: bool,
/// Push bookmarks pointing to these commits (can be repeated)
#[arg(long, short)]
#[arg(long, short, value_name = "REVSETS")]
revisions: Vec<RevisionArg>,
/// Push this commit by creating a bookmark based on its change ID (can be
/// repeated)
///
/// The created bookmark will be tracked automatically. Use the
/// `git.push-bookmark-prefix` setting to change the prefix for generated
/// names.
#[arg(long, short)]
#[arg(long, short, value_name = "REVSETS")]
change: Vec<RevisionArg>,
/// Only display what will change on the remote
#[arg(long)]
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/git/submodule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub fn cmd_git_submodule(
#[command(hide = true)]
pub struct PrintArgs {
/// Read .gitmodules from the given revision.
#[arg(long, short = 'r', default_value = "@")]
#[arg(long, short = 'r', default_value = "@", value_name = "REVSET")]
revisions: RevisionArg,
}

Expand Down
Loading
Loading