author | Pierre-Yves David <pierre-yves.david@octobus.net> |
Tue, 11 Mar 2025 02:29:42 +0100 | |
branch | stable |
changeset 53042 | cdd7bf612c7b |
parent 52557 | b89c934e6269 |
permissions | -rw-r--r-- |
52557
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
1 |
use clap::Arg; |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
2 |
use hg::matchers::ReSyntax; |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
3 |
|
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
4 |
use crate::error::CommandError; |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
5 |
|
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
6 |
use super::debugignorerhg::WhichPatterns; |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
7 |
|
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
8 |
pub const HELP_TEXT: &str = " |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
9 |
Show effective hgignore patterns used by rhg. |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
10 |
|
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
11 |
This is a pure Rust version of `hg debugignore`. |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
12 |
|
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
13 |
Some options might be missing, check the list below. |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
14 |
"; |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
15 |
|
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
16 |
pub fn args() -> clap::Command { |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
17 |
clap::command!("script::hgignore") |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
18 |
.arg( |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
19 |
Arg::new("print-re") |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
20 |
.help("Print the regular expression that matches all ignored files.") |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
21 |
.action(clap::ArgAction::SetTrue) |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
22 |
.long("print-re"), |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
23 |
).about(HELP_TEXT) |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
24 |
} |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
25 |
|
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
26 |
pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> { |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
27 |
let repo = invocation.repo?; |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
28 |
let args = invocation.subcommand_args; |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
29 |
let print_re = args.get_flag("print-re"); |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
30 |
if !print_re { |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
31 |
return Err(CommandError::unsupported( |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
32 |
"Unsupported invocation: flag --print-re is required", |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
33 |
)); |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
34 |
} |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
35 |
|
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
36 |
crate::commands::debugignorerhg::work( |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
37 |
repo, |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
38 |
invocation.ui, |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
39 |
WhichPatterns::All, |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
40 |
ReSyntax::Tidy, |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
41 |
) |
b89c934e6269
rust-hgignore: add a scripting command to print the hgignore regexp
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
42 |
} |