Debian Codegraph @

rust/rhg/src/commands/script_hgignore.rs

raw
1 use clap::Arg;
2 use hg::matchers::ReSyntax;
3
4 use super::debugignorerhg::WhichPatterns;
5 use crate::error::CommandError;
6
7 pub const HELP_TEXT: &str = "
8 Show effective hgignore patterns used by rhg.
9
10 This is a pure Rust version of `hg debugignore`.
11
12 Some options might be missing, check the list below.
13 ";
14
15 pub fn args() -> clap::Command {
16 clap::command!("script::hgignore")
17 .args_override_self(true)
18 .arg(
19 Arg::new("print-re")
20 .help("Print the regular expression that matches all ignored files.")
21 .action(clap::ArgAction::SetTrue)
22 .long("print-re"),
23 ).about(HELP_TEXT)
24 }
25
26 pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> {
27 let repo = invocation.repo?;
28 let args = invocation.subcommand_args;
29 let print_re = args.get_flag("print-re");
30 if !print_re {
31 return Err(CommandError::unsupported(
32 "Unsupported invocation: flag --print-re is required",
33 ));
34 }
35
36 crate::commands::debugignorerhg::work(
37 repo,
38 invocation.ui,
39 WhichPatterns::All,
40 ReSyntax::Tidy,
41 )
42 }