##// END OF EJS Templates
rhg: Move subcommand CLI arguments definitions to respective modules...
Simon Sapin -
r47229:d5896fad default draft
parent child Browse files
Show More
@@ -1,5 +1,6 b''
1 1 use crate::error::CommandError;
2 2 use crate::ui::Ui;
3 use clap::Arg;
3 4 use clap::ArgMatches;
4 5 use hg::config::Config;
5 6 use hg::operations::cat;
@@ -12,6 +13,27 b' pub const HELP_TEXT: &str = "'
12 13 Output the current or given revision of files
13 14 ";
14 15
16 pub fn args() -> clap::App<'static, 'static> {
17 clap::SubCommand::with_name("cat")
18 .arg(
19 Arg::with_name("rev")
20 .help("search the repository as it is in REV")
21 .short("-r")
22 .long("--revision")
23 .value_name("REV")
24 .takes_value(true),
25 )
26 .arg(
27 clap::Arg::with_name("files")
28 .required(true)
29 .multiple(true)
30 .empty_values(false)
31 .value_name("FILE")
32 .help("Activity to start: activity@category"),
33 )
34 .about(HELP_TEXT)
35 }
36
15 37 #[timed]
16 38 pub fn run(
17 39 ui: &Ui,
@@ -1,5 +1,7 b''
1 1 use crate::error::CommandError;
2 2 use crate::ui::Ui;
3 use clap::Arg;
4 use clap::ArgGroup;
3 5 use clap::ArgMatches;
4 6 use hg::config::Config;
5 7 use hg::operations::{debug_data, DebugDataKind};
@@ -10,6 +12,34 b' pub const HELP_TEXT: &str = "'
10 12 Dump the contents of a data file revision
11 13 ";
12 14
15 pub fn args() -> clap::App<'static, 'static> {
16 clap::SubCommand::with_name("debugdata")
17 .arg(
18 Arg::with_name("changelog")
19 .help("open changelog")
20 .short("-c")
21 .long("--changelog"),
22 )
23 .arg(
24 Arg::with_name("manifest")
25 .help("open manifest")
26 .short("-m")
27 .long("--manifest"),
28 )
29 .group(
30 ArgGroup::with_name("")
31 .args(&["changelog", "manifest"])
32 .required(true),
33 )
34 .arg(
35 Arg::with_name("rev")
36 .help("revision")
37 .required(true)
38 .value_name("REV"),
39 )
40 .about(HELP_TEXT)
41 }
42
13 43 #[timed]
14 44 pub fn run(
15 45 ui: &Ui,
@@ -8,6 +8,10 b' pub const HELP_TEXT: &str = "'
8 8 Print the current repo requirements.
9 9 ";
10 10
11 pub fn args() -> clap::App<'static, 'static> {
12 clap::SubCommand::with_name("debugrequirements").about(HELP_TEXT)
13 }
14
11 15 pub fn run(
12 16 ui: &Ui,
13 17 config: &Config,
@@ -1,5 +1,6 b''
1 1 use crate::error::CommandError;
2 2 use crate::ui::Ui;
3 use clap::Arg;
3 4 use clap::ArgMatches;
4 5 use hg::config::Config;
5 6 use hg::operations::list_rev_tracked_files;
@@ -14,6 +15,19 b' List tracked files.'
14 15 Returns 0 on success.
15 16 ";
16 17
18 pub fn args() -> clap::App<'static, 'static> {
19 clap::SubCommand::with_name("files")
20 .arg(
21 Arg::with_name("rev")
22 .help("search the repository as it is in REV")
23 .short("-r")
24 .long("--revision")
25 .value_name("REV")
26 .takes_value(true),
27 )
28 .about(HELP_TEXT)
29 }
30
17 31 pub fn run(
18 32 ui: &Ui,
19 33 config: &Config,
@@ -12,6 +12,10 b' Print the root directory of the current '
12 12 Returns 0 on success.
13 13 ";
14 14
15 pub fn args() -> clap::App<'static, 'static> {
16 clap::SubCommand::with_name("root").about(HELP_TEXT)
17 }
18
15 19 pub fn run(
16 20 ui: &Ui,
17 21 config: &Config,
@@ -1,10 +1,7 b''
1 1 extern crate log;
2 2 use clap::App;
3 3 use clap::AppSettings;
4 use clap::Arg;
5 use clap::ArgGroup;
6 4 use clap::ArgMatches;
7 use clap::SubCommand;
8 5 use format_bytes::format_bytes;
9 6
10 7 mod commands;
@@ -20,72 +17,11 b' fn main() {'
20 17 .setting(AppSettings::SubcommandRequired)
21 18 .setting(AppSettings::VersionlessSubcommands)
22 19 .version("0.0.1")
23 .subcommand(
24 SubCommand::with_name("root").about(commands::root::HELP_TEXT),
25 )
26 .subcommand(
27 SubCommand::with_name("files")
28 .arg(
29 Arg::with_name("rev")
30 .help("search the repository as it is in REV")
31 .short("-r")
32 .long("--revision")
33 .value_name("REV")
34 .takes_value(true),
35 )
36 .about(commands::files::HELP_TEXT),
37 )
38 .subcommand(
39 SubCommand::with_name("cat")
40 .arg(
41 Arg::with_name("rev")
42 .help("search the repository as it is in REV")
43 .short("-r")
44 .long("--revision")
45 .value_name("REV")
46 .takes_value(true),
47 )
48 .arg(
49 clap::Arg::with_name("files")
50 .required(true)
51 .multiple(true)
52 .empty_values(false)
53 .value_name("FILE")
54 .help("Activity to start: activity@category"),
55 )
56 .about(commands::cat::HELP_TEXT),
57 )
58 .subcommand(
59 SubCommand::with_name("debugdata")
60 .about(commands::debugdata::HELP_TEXT)
61 .arg(
62 Arg::with_name("changelog")
63 .help("open changelog")
64 .short("-c")
65 .long("--changelog"),
66 )
67 .arg(
68 Arg::with_name("manifest")
69 .help("open manifest")
70 .short("-m")
71 .long("--manifest"),
72 )
73 .group(
74 ArgGroup::with_name("")
75 .args(&["changelog", "manifest"])
76 .required(true),
77 )
78 .arg(
79 Arg::with_name("rev")
80 .help("revision")
81 .required(true)
82 .value_name("REV"),
83 ),
84 )
85 .subcommand(
86 SubCommand::with_name("debugrequirements")
87 .about(commands::debugrequirements::HELP_TEXT),
88 );
20 .subcommand(commands::root::args())
21 .subcommand(commands::files::args())
22 .subcommand(commands::cat::args())
23 .subcommand(commands::debugdata::args())
24 .subcommand(commands::debugrequirements::args());
89 25
90 26 let matches = app.clone().get_matches_safe().unwrap_or_else(|err| {
91 27 let _ = ui::Ui::new().writeln_stderr_str(&err.message);
General Comments 0
You need to be logged in to leave comments. Login now