##// END OF EJS Templates
rhg: add a limited `rhg root` subcommand...
Antoine Cezar -
r45593:18f8d3b3 default
parent child Browse files
Show More
@@ -0,0 +1,26 b''
1 #require rust
2
3 $ rhg() {
4 > if [ -f "$RUNTESTDIR/../rust/target/debug/rhg" ]; then
5 > "$RUNTESTDIR/../rust/target/debug/rhg" "$@"
6 > else
7 > echo "skipped: Cannot find rhg. Try to run cargo build in rust/rhg."
8 > exit 80
9 > fi
10 > }
11 $ rhg unimplemented-command
12 [252]
13 $ rhg root
14 abort: no repository found in '$TESTTMP' (.hg not found)!
15 [255]
16 $ hg init repository
17 $ cd repository
18 $ rhg root
19 $TESTTMP/repository
20 $ rhg root > /dev/full
21 abort: No space left on device (os error 28)
22 [255]
23 $ rm -rf `pwd`
24 $ rhg root
25 abort: error getting current working directory: $ENOENT$
26 [255]
@@ -58,7 +58,7 b' dependencies = ['
58
58
59 [[package]]
59 [[package]]
60 name = "clap"
60 name = "clap"
61 version = "2.33.0"
61 version = "2.33.1"
62 source = "registry+https://github.com/rust-lang/crates.io-index"
62 source = "registry+https://github.com/rust-lang/crates.io-index"
63 dependencies = [
63 dependencies = [
64 "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
64 "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -203,7 +203,7 b' name = "hg-core"'
203 version = "0.1.0"
203 version = "0.1.0"
204 dependencies = [
204 dependencies = [
205 "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
205 "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
206 "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
206 "clap 2.33.1 (registry+https://github.com/rust-lang/crates.io-index)",
207 "crossbeam 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
207 "crossbeam 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
208 "hex 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
208 "hex 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
209 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
209 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -490,6 +490,7 b' dependencies = ['
490 name = "rhg"
490 name = "rhg"
491 version = "0.1.0"
491 version = "0.1.0"
492 dependencies = [
492 dependencies = [
493 "clap 2.33.1 (registry+https://github.com/rust-lang/crates.io-index)",
493 "hg-core 0.1.0",
494 "hg-core 0.1.0",
494 ]
495 ]
495
496
@@ -657,7 +658,7 b' source = "registry+https://github.com/ru'
657 "checksum byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
658 "checksum byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
658 "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
659 "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
659 "checksum chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "80094f509cf8b5ae86a4966a39b3ff66cd7e2a3e594accec3743ff3fabeab5b2"
660 "checksum chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "80094f509cf8b5ae86a4966a39b3ff66cd7e2a3e594accec3743ff3fabeab5b2"
660 "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9"
661 "checksum clap 2.33.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bdfa80d47f954d53a35a64987ca1422f495b8d6483c0fe9f7117b36c2a792129"
661 "checksum colored 1.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f4ffc801dacf156c5854b9df4f425a626539c3a6ef7893cc0c5084a23f0b6c59"
662 "checksum colored 1.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f4ffc801dacf156c5854b9df4f425a626539c3a6ef7893cc0c5084a23f0b6c59"
662 "checksum cpython 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bfaf3847ab963e40c4f6dd8d6be279bdf74007ae2413786a0dcbb28c52139a95"
663 "checksum cpython 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bfaf3847ab963e40c4f6dd8d6be279bdf74007ae2413786a0dcbb28c52139a95"
663 "checksum crossbeam 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "69323bff1fb41c635347b8ead484a5ca6c3f11914d784170b158d8449ab07f8e"
664 "checksum crossbeam 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "69323bff1fb41c635347b8ead484a5ca6c3f11914d784170b158d8449ab07f8e"
@@ -6,4 +6,5 b' edition = "2018"'
6
6
7 [dependencies]
7 [dependencies]
8 hg-core = { path = "../hg-core"}
8 hg-core = { path = "../hg-core"}
9 clap = "2.33.1"
9
10
@@ -1,8 +1,42 b''
1 use clap::App;
2 use clap::AppSettings;
3 use clap::SubCommand;
4
1 mod commands;
5 mod commands;
2 mod error;
6 mod error;
3 mod exitcode;
7 mod exitcode;
4 mod ui;
8 mod ui;
9 use commands::Command;
5
10
6 fn main() {
11 fn main() {
7 std::process::exit(exitcode::UNIMPLEMENTED_COMMAND)
12 let mut app = App::new("rhg")
13 .setting(AppSettings::AllowInvalidUtf8)
14 .setting(AppSettings::SubcommandRequired)
15 .setting(AppSettings::VersionlessSubcommands)
16 .version("0.0.1")
17 .subcommand(
18 SubCommand::with_name("root").about(commands::root::HELP_TEXT),
19 );
20
21 let matches = app.clone().get_matches_safe().unwrap_or_else(|_| {
22 std::process::exit(exitcode::UNIMPLEMENTED_COMMAND)
23 });
24
25 let command_result = match matches.subcommand_name() {
26 Some(name) => match name {
27 "root" => commands::root::RootCommand::new().run(),
28 _ => std::process::exit(exitcode::UNIMPLEMENTED_COMMAND),
29 },
30 _ => {
31 match app.print_help() {
32 Ok(_) => std::process::exit(exitcode::OK),
33 Err(_) => std::process::exit(exitcode::ABORT),
34 };
35 }
36 };
37
38 match command_result {
39 Ok(_) => std::process::exit(exitcode::OK),
40 Err(e) => e.exit(),
41 }
8 }
42 }
General Comments 0
You need to be logged in to leave comments. Login now