Mercurial > hg
annotate rust/rhg/src/commands/debugrequirements.rs @ 46592:80840b651721
rhg: Group values passed to every sub-command into a struct
The set of which values this is is evidently not stable yet,
so this will make changes easier. Also it is growing, and the function
signatures are getting out hand.
Differential Revision: https://phab.mercurial-scm.org/D10003
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Mon, 15 Feb 2021 20:05:32 +0100 |
parents | d8730ff51d5a |
children | 5ce2aa7c2ad5 |
rev | line source |
---|---|
45924
a2eda1ff22aa
requirements: move loading to hg-core and add parsing
Simon Sapin <simon-commits@exyr.org>
parents:
45923
diff
changeset
|
1 use crate::error::CommandError; |
46167
8a4914397d02
rust: introduce Repo and Vfs types for filesystem abstraction
Simon Sapin <simon.sapin@octobus.net>
parents:
46135
diff
changeset
|
2 use hg::repo::Repo; |
45923
ead435aa5294
rhg: add a `debugrequirements` subcommand
Simon Sapin <simon-commits@exyr.org>
parents:
diff
changeset
|
3 |
ead435aa5294
rhg: add a `debugrequirements` subcommand
Simon Sapin <simon-commits@exyr.org>
parents:
diff
changeset
|
4 pub const HELP_TEXT: &str = " |
ead435aa5294
rhg: add a `debugrequirements` subcommand
Simon Sapin <simon-commits@exyr.org>
parents:
diff
changeset
|
5 Print the current repo requirements. |
ead435aa5294
rhg: add a `debugrequirements` subcommand
Simon Sapin <simon-commits@exyr.org>
parents:
diff
changeset
|
6 "; |
ead435aa5294
rhg: add a `debugrequirements` subcommand
Simon Sapin <simon-commits@exyr.org>
parents:
diff
changeset
|
7 |
46501
1ecaf09d9964
rhg: Move subcommand CLI arguments definitions to respective modules
Simon Sapin <simon.sapin@octobus.net>
parents:
46500
diff
changeset
|
8 pub fn args() -> clap::App<'static, 'static> { |
1ecaf09d9964
rhg: Move subcommand CLI arguments definitions to respective modules
Simon Sapin <simon.sapin@octobus.net>
parents:
46500
diff
changeset
|
9 clap::SubCommand::with_name("debugrequirements").about(HELP_TEXT) |
1ecaf09d9964
rhg: Move subcommand CLI arguments definitions to respective modules
Simon Sapin <simon.sapin@octobus.net>
parents:
46500
diff
changeset
|
10 } |
1ecaf09d9964
rhg: Move subcommand CLI arguments definitions to respective modules
Simon Sapin <simon.sapin@octobus.net>
parents:
46500
diff
changeset
|
11 |
46592
80840b651721
rhg: Group values passed to every sub-command into a struct
Simon Sapin <simon.sapin@octobus.net>
parents:
46503
diff
changeset
|
12 pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> { |
80840b651721
rhg: Group values passed to every sub-command into a struct
Simon Sapin <simon.sapin@octobus.net>
parents:
46503
diff
changeset
|
13 let repo = Repo::find(invocation.non_repo_config, invocation.repo_path)?; |
46500
184e46550dc8
rhg: replace command structs with functions
Simon Sapin <simon.sapin@octobus.net>
parents:
46484
diff
changeset
|
14 let mut output = String::new(); |
184e46550dc8
rhg: replace command structs with functions
Simon Sapin <simon.sapin@octobus.net>
parents:
46484
diff
changeset
|
15 let mut requirements: Vec<_> = repo.requirements().iter().collect(); |
184e46550dc8
rhg: replace command structs with functions
Simon Sapin <simon.sapin@octobus.net>
parents:
46484
diff
changeset
|
16 requirements.sort(); |
184e46550dc8
rhg: replace command structs with functions
Simon Sapin <simon.sapin@octobus.net>
parents:
46484
diff
changeset
|
17 for req in requirements { |
184e46550dc8
rhg: replace command structs with functions
Simon Sapin <simon.sapin@octobus.net>
parents:
46484
diff
changeset
|
18 output.push_str(req); |
184e46550dc8
rhg: replace command structs with functions
Simon Sapin <simon.sapin@octobus.net>
parents:
46484
diff
changeset
|
19 output.push('\n'); |
45923
ead435aa5294
rhg: add a `debugrequirements` subcommand
Simon Sapin <simon-commits@exyr.org>
parents:
diff
changeset
|
20 } |
46592
80840b651721
rhg: Group values passed to every sub-command into a struct
Simon Sapin <simon.sapin@octobus.net>
parents:
46503
diff
changeset
|
21 invocation.ui.write_stdout(output.as_bytes())?; |
46500
184e46550dc8
rhg: replace command structs with functions
Simon Sapin <simon.sapin@octobus.net>
parents:
46484
diff
changeset
|
22 Ok(()) |
45923
ead435aa5294
rhg: add a `debugrequirements` subcommand
Simon Sapin <simon-commits@exyr.org>
parents:
diff
changeset
|
23 } |