Mercurial > hg-stable
annotate rust/rhg/src/main.rs @ 46557:a25033eb43b5
rhg: add limited support for the `config` sub-command
Only with one argument and no flag. This is mostly for testing.
Differential Revision: https://phab.mercurial-scm.org/D9972
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Mon, 08 Feb 2021 23:41:58 +0100 |
parents | 2e5dd18d6dc3 |
children | 21d3b40b4c0e |
rev | line source |
---|---|
45536
b1cea0dc9db0
rhg: Add debug timing
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45535
diff
changeset
|
1 extern crate log; |
45051
18f8d3b31baa
rhg: add a limited `rhg root` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45050
diff
changeset
|
2 use clap::App; |
18f8d3b31baa
rhg: add a limited `rhg root` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45050
diff
changeset
|
3 use clap::AppSettings; |
46555
d8730ff51d5a
rhg: Add support for -R and --repository command-line arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46554
diff
changeset
|
4 use clap::Arg; |
45535
f17caf8f3fef
rhg: add a limited `rhg debugdata` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45451
diff
changeset
|
5 use clap::ArgMatches; |
46513
ca3f73cc3cf4
rhg: Simplify CommandError based on its use
Simon Sapin <simon.sapin@octobus.net>
parents:
45938
diff
changeset
|
6 use format_bytes::format_bytes; |
46555
d8730ff51d5a
rhg: Add support for -R and --repository command-line arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46554
diff
changeset
|
7 use std::path::Path; |
45051
18f8d3b31baa
rhg: add a limited `rhg root` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45050
diff
changeset
|
8 |
45002
bacf6c7ef01b
rhg: add Command trait for subcommands implemented by rhg
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45001
diff
changeset
|
9 mod error; |
45001 | 10 mod exitcode; |
45050
513b3ef277a3
rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45002
diff
changeset
|
11 mod ui; |
45535
f17caf8f3fef
rhg: add a limited `rhg debugdata` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45451
diff
changeset
|
12 use error::CommandError; |
45001 | 13 |
46555
d8730ff51d5a
rhg: Add support for -R and --repository command-line arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46554
diff
changeset
|
14 fn add_global_args<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> { |
d8730ff51d5a
rhg: Add support for -R and --repository command-line arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46554
diff
changeset
|
15 app.arg( |
d8730ff51d5a
rhg: Add support for -R and --repository command-line arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46554
diff
changeset
|
16 Arg::with_name("repository") |
d8730ff51d5a
rhg: Add support for -R and --repository command-line arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46554
diff
changeset
|
17 .help("repository root directory") |
d8730ff51d5a
rhg: Add support for -R and --repository command-line arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46554
diff
changeset
|
18 .short("-R") |
d8730ff51d5a
rhg: Add support for -R and --repository command-line arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46554
diff
changeset
|
19 .long("--repository") |
d8730ff51d5a
rhg: Add support for -R and --repository command-line arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46554
diff
changeset
|
20 .value_name("REPO") |
d8730ff51d5a
rhg: Add support for -R and --repository command-line arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46554
diff
changeset
|
21 .takes_value(true), |
d8730ff51d5a
rhg: Add support for -R and --repository command-line arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46554
diff
changeset
|
22 ) |
46556
2e5dd18d6dc3
rhg: Add support for --config CLI arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46555
diff
changeset
|
23 .arg( |
2e5dd18d6dc3
rhg: Add support for --config CLI arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46555
diff
changeset
|
24 Arg::with_name("config") |
2e5dd18d6dc3
rhg: Add support for --config CLI arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46555
diff
changeset
|
25 .help("set/override config option (use 'section.name=value')") |
2e5dd18d6dc3
rhg: Add support for --config CLI arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46555
diff
changeset
|
26 .long("--config") |
2e5dd18d6dc3
rhg: Add support for --config CLI arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46555
diff
changeset
|
27 .value_name("CONFIG") |
2e5dd18d6dc3
rhg: Add support for --config CLI arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46555
diff
changeset
|
28 .takes_value(true) |
2e5dd18d6dc3
rhg: Add support for --config CLI arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46555
diff
changeset
|
29 // Ok: `--config section.key1=val --config section.key2=val2` |
2e5dd18d6dc3
rhg: Add support for --config CLI arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46555
diff
changeset
|
30 .multiple(true) |
2e5dd18d6dc3
rhg: Add support for --config CLI arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46555
diff
changeset
|
31 // Not ok: `--config section.key1=val section.key2=val2` |
2e5dd18d6dc3
rhg: Add support for --config CLI arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46555
diff
changeset
|
32 .number_of_values(1), |
2e5dd18d6dc3
rhg: Add support for --config CLI arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46555
diff
changeset
|
33 ) |
46555
d8730ff51d5a
rhg: Add support for -R and --repository command-line arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46554
diff
changeset
|
34 } |
d8730ff51d5a
rhg: Add support for -R and --repository command-line arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46554
diff
changeset
|
35 |
45001 | 36 fn main() { |
45536
b1cea0dc9db0
rhg: Add debug timing
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45535
diff
changeset
|
37 env_logger::init(); |
45535
f17caf8f3fef
rhg: add a limited `rhg debugdata` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45451
diff
changeset
|
38 let app = App::new("rhg") |
45051
18f8d3b31baa
rhg: add a limited `rhg root` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45050
diff
changeset
|
39 .setting(AppSettings::AllowInvalidUtf8) |
18f8d3b31baa
rhg: add a limited `rhg root` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45050
diff
changeset
|
40 .setting(AppSettings::SubcommandRequired) |
18f8d3b31baa
rhg: add a limited `rhg root` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45050
diff
changeset
|
41 .setting(AppSettings::VersionlessSubcommands) |
46554
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
42 .version("0.0.1"); |
46555
d8730ff51d5a
rhg: Add support for -R and --repository command-line arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46554
diff
changeset
|
43 let app = add_global_args(app); |
46554
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
44 let app = add_subcommand_args(app); |
45051
18f8d3b31baa
rhg: add a limited `rhg root` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45050
diff
changeset
|
45 |
45381
47997afadf08
rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45051
diff
changeset
|
46 let ui = ui::Ui::new(); |
47997afadf08
rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45051
diff
changeset
|
47 |
46554
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
48 let matches = app.clone().get_matches_safe().unwrap_or_else(|err| { |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
49 let _ = ui.writeln_stderr_str(&err.message); |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
50 std::process::exit(exitcode::UNIMPLEMENTED) |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
51 }); |
46555
d8730ff51d5a
rhg: Add support for -R and --repository command-line arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46554
diff
changeset
|
52 |
46554
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
53 let (subcommand_name, subcommand_matches) = matches.subcommand(); |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
54 let run = subcommand_run_fn(subcommand_name) |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
55 .expect("unknown subcommand name from clap despite AppSettings::SubcommandRequired"); |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
56 let args = subcommand_matches |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
57 .expect("no subcommand arguments from clap despite AppSettings::SubcommandRequired"); |
45051
18f8d3b31baa
rhg: add a limited `rhg root` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45050
diff
changeset
|
58 |
46555
d8730ff51d5a
rhg: Add support for -R and --repository command-line arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46554
diff
changeset
|
59 // Global arguments can be in either based on e.g. `hg -R ./foo log` v.s. |
d8730ff51d5a
rhg: Add support for -R and --repository command-line arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46554
diff
changeset
|
60 // `hg log -R ./foo` |
46556
2e5dd18d6dc3
rhg: Add support for --config CLI arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46555
diff
changeset
|
61 let value_of_global_arg = |
46555
d8730ff51d5a
rhg: Add support for -R and --repository command-line arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46554
diff
changeset
|
62 |name| args.value_of_os(name).or_else(|| matches.value_of_os(name)); |
46556
2e5dd18d6dc3
rhg: Add support for --config CLI arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46555
diff
changeset
|
63 // For arguments where multiple occurences are allowed, return a |
2e5dd18d6dc3
rhg: Add support for --config CLI arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46555
diff
changeset
|
64 // possibly-iterator of all values. |
2e5dd18d6dc3
rhg: Add support for --config CLI arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46555
diff
changeset
|
65 let values_of_global_arg = |name: &str| { |
2e5dd18d6dc3
rhg: Add support for --config CLI arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46555
diff
changeset
|
66 let a = matches.values_of_os(name).into_iter().flatten(); |
2e5dd18d6dc3
rhg: Add support for --config CLI arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46555
diff
changeset
|
67 let b = args.values_of_os(name).into_iter().flatten(); |
2e5dd18d6dc3
rhg: Add support for --config CLI arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46555
diff
changeset
|
68 a.chain(b) |
2e5dd18d6dc3
rhg: Add support for --config CLI arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46555
diff
changeset
|
69 }; |
46555
d8730ff51d5a
rhg: Add support for -R and --repository command-line arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46554
diff
changeset
|
70 |
46556
2e5dd18d6dc3
rhg: Add support for --config CLI arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46555
diff
changeset
|
71 let repo_path = value_of_global_arg("repository").map(Path::new); |
46554
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
72 let result = (|| -> Result<(), CommandError> { |
46556
2e5dd18d6dc3
rhg: Add support for --config CLI arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46555
diff
changeset
|
73 let config_args = values_of_global_arg("config") |
2e5dd18d6dc3
rhg: Add support for --config CLI arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46555
diff
changeset
|
74 // `get_bytes_from_path` works for OsStr the same as for Path |
2e5dd18d6dc3
rhg: Add support for --config CLI arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46555
diff
changeset
|
75 .map(hg::utils::files::get_bytes_from_path); |
2e5dd18d6dc3
rhg: Add support for --config CLI arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46555
diff
changeset
|
76 let config = hg::config::Config::load(config_args)?; |
46555
d8730ff51d5a
rhg: Add support for -R and --repository command-line arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46554
diff
changeset
|
77 run(&ui, &config, repo_path, args) |
46554
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
78 })(); |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
79 |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
80 let exit_code = match result { |
46513
ca3f73cc3cf4
rhg: Simplify CommandError based on its use
Simon Sapin <simon.sapin@octobus.net>
parents:
45938
diff
changeset
|
81 Ok(_) => exitcode::OK, |
ca3f73cc3cf4
rhg: Simplify CommandError based on its use
Simon Sapin <simon.sapin@octobus.net>
parents:
45938
diff
changeset
|
82 |
ca3f73cc3cf4
rhg: Simplify CommandError based on its use
Simon Sapin <simon.sapin@octobus.net>
parents:
45938
diff
changeset
|
83 // Exit with a specific code and no error message to let a potential |
ca3f73cc3cf4
rhg: Simplify CommandError based on its use
Simon Sapin <simon.sapin@octobus.net>
parents:
45938
diff
changeset
|
84 // wrapper script fallback to Python-based Mercurial. |
ca3f73cc3cf4
rhg: Simplify CommandError based on its use
Simon Sapin <simon.sapin@octobus.net>
parents:
45938
diff
changeset
|
85 Err(CommandError::Unimplemented) => exitcode::UNIMPLEMENTED, |
ca3f73cc3cf4
rhg: Simplify CommandError based on its use
Simon Sapin <simon.sapin@octobus.net>
parents:
45938
diff
changeset
|
86 |
ca3f73cc3cf4
rhg: Simplify CommandError based on its use
Simon Sapin <simon.sapin@octobus.net>
parents:
45938
diff
changeset
|
87 Err(CommandError::Abort { message }) => { |
ca3f73cc3cf4
rhg: Simplify CommandError based on its use
Simon Sapin <simon.sapin@octobus.net>
parents:
45938
diff
changeset
|
88 if !message.is_empty() { |
ca3f73cc3cf4
rhg: Simplify CommandError based on its use
Simon Sapin <simon.sapin@octobus.net>
parents:
45938
diff
changeset
|
89 // Ignore errors when writing to stderr, we’re already exiting |
ca3f73cc3cf4
rhg: Simplify CommandError based on its use
Simon Sapin <simon.sapin@octobus.net>
parents:
45938
diff
changeset
|
90 // with failure code so there’s not much more we can do. |
ca3f73cc3cf4
rhg: Simplify CommandError based on its use
Simon Sapin <simon.sapin@octobus.net>
parents:
45938
diff
changeset
|
91 let _ = |
ca3f73cc3cf4
rhg: Simplify CommandError based on its use
Simon Sapin <simon.sapin@octobus.net>
parents:
45938
diff
changeset
|
92 ui.write_stderr(&format_bytes!(b"abort: {}\n", message)); |
ca3f73cc3cf4
rhg: Simplify CommandError based on its use
Simon Sapin <simon.sapin@octobus.net>
parents:
45938
diff
changeset
|
93 } |
ca3f73cc3cf4
rhg: Simplify CommandError based on its use
Simon Sapin <simon.sapin@octobus.net>
parents:
45938
diff
changeset
|
94 exitcode::ABORT |
45381
47997afadf08
rhg: ask the error message from `CommandError`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45051
diff
changeset
|
95 } |
46513
ca3f73cc3cf4
rhg: Simplify CommandError based on its use
Simon Sapin <simon.sapin@octobus.net>
parents:
45938
diff
changeset
|
96 }; |
ca3f73cc3cf4
rhg: Simplify CommandError based on its use
Simon Sapin <simon.sapin@octobus.net>
parents:
45938
diff
changeset
|
97 std::process::exit(exit_code) |
45001 | 98 } |
45535
f17caf8f3fef
rhg: add a limited `rhg debugdata` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45451
diff
changeset
|
99 |
46554
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
100 macro_rules! subcommands { |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
101 ($( $command: ident )+) => { |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
102 mod commands { |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
103 $( |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
104 pub mod $command; |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
105 )+ |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
106 } |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
107 |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
108 fn add_subcommand_args<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> { |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
109 app |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
110 $( |
46555
d8730ff51d5a
rhg: Add support for -R and --repository command-line arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46554
diff
changeset
|
111 .subcommand(add_global_args(commands::$command::args())) |
46554
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
112 )+ |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
113 } |
46543
a6e4e4650bac
rhg: Parse system and user configuration at program start
Simon Sapin <simon.sapin@octobus.net>
parents:
46513
diff
changeset
|
114 |
46554
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
115 fn subcommand_run_fn(name: &str) -> Option<fn( |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
116 &ui::Ui, |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
117 &hg::config::Config, |
46555
d8730ff51d5a
rhg: Add support for -R and --repository command-line arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
46554
diff
changeset
|
118 Option<&Path>, |
46554
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
119 &ArgMatches, |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
120 ) -> Result<(), CommandError>> { |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
121 match name { |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
122 $( |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
123 stringify!($command) => Some(commands::$command::run), |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
124 )+ |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
125 _ => None, |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
126 } |
45548
33ded2d3f4fc
rhg: add a limited `rhg cat -r` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45543
diff
changeset
|
127 } |
46554
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
128 }; |
45535
f17caf8f3fef
rhg: add a limited `rhg debugdata` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45451
diff
changeset
|
129 } |
46554
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
130 |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
131 subcommands! { |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
132 cat |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
133 debugdata |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
134 debugrequirements |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
135 files |
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
136 root |
46557
a25033eb43b5
rhg: add limited support for the `config` sub-command
Simon Sapin <simon.sapin@octobus.net>
parents:
46556
diff
changeset
|
137 config |
46554
95d37db31479
rhg: Replace subcommand boilerplate with a macro
Simon Sapin <simon.sapin@octobus.net>
parents:
46553
diff
changeset
|
138 } |