chore(rome_cli): Update to
MODIFY
Cargo.lock
Cargo.lock
@@ -205,33 +205,18 @@ dependencies = [
[[package]]
name = "clap"
-version = "3.0.0-beta.4"
+version = "3.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fcd70aa5597dbc42f7217a543f9ef2768b2ef823ba29036072d30e1d88e98406"
+checksum = "8c506244a13c87262f84bf16369740d0b7c3850901b6a642aa41b031a710c473"
dependencies = [
"atty",
"bitflags",
- "clap_derive",
"indexmap",
"lazy_static",
"os_str_bytes",
"strsim",
"termcolor",
"textwrap 0.14.2",
- "vec_map",
-]
-
-[[package]]
-name = "clap_derive"
-version = "3.0.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "517358c28fcef6607bf6f76108e02afad7e82297d132a6b846dcc1fc3efcd153"
-dependencies = [
- "heck 0.4.0",
- "proc-macro-error",
- "proc-macro2",
- "quote",
- "syn",
]
[[package]]
@@ -632,12 +617,6 @@ dependencies = [
"unicode-segmentation",
]
-[[package]]
-name = "heck"
-version = "0.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
-
[[package]]
name = "hermit-abi"
version = "0.1.19"
@@ -869,7 +848,7 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca1d48da0e4a6100b4afd52fae99f36d47964a209624021280ad9ffdd410e83d"
dependencies = [
- "heck 0.3.3",
+ "heck",
"proc-macro2",
"quote",
"syn",
@@ -1006,9 +985,12 @@ checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575"
[[package]]
name = "os_str_bytes"
-version = "3.1.0"
+version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6acbef58a60fe69ab50510a55bc8cdd4d6cf2283d27ad338f54cb52747a9cf2d"
+checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
+dependencies = [
+ "memchr",
+]
[[package]]
name = "parking_lot"
@@ -1265,7 +1247,7 @@ dependencies = [
name = "rome_cli"
version = "0.0.0"
dependencies = [
- "clap 3.0.0-beta.4",
+ "clap 3.0.9",
"rome_core",
"rome_formatter",
"rome_path",
@@ -1689,9 +1671,6 @@ name = "textwrap"
version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80"
-dependencies = [
- "unicode-width",
-]
[[package]]
name = "thiserror"
@@ -1982,12 +1961,6 @@ version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7"
-[[package]]
-name = "vec_map"
-version = "0.8.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
-
[[package]]
name = "version_check"
version = "0.9.4"

MODIFY
crates/rome_cli/Cargo.toml
crates/rome_cli/Cargo.toml
@@ -6,7 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-clap = "3.0.0-beta.4"
rome_formatter = { path = "../rome_formatter" }
rome_core = { path = "../rome_core", version = "0.0.0" }
rome_path = { path = "../rome_path", version = "0.0.0" }
+clap = {version = "3.0.9", features = ["cargo"]}

MODIFY
crates/rome_cli/src/lib.rs
crates/rome_cli/src/lib.rs
@@ -6,7 +6,7 @@ use std::{path::PathBuf, str::FromStr};
/// Main function to run Rome CLI
pub fn run_cli() {
- let matches = App::new("rome")
+ let cli_app = App::new("rome")
.about("The official Rome CLI")
.version(crate_version!())
.setting(AppSettings::SubcommandRequiredElseHelp)
@@ -16,7 +16,7 @@ pub fn run_cli() {
.arg(
Arg::new("indent_style")
.long("indent-style")
- .about("The style of indentation")
+ .help("The style of indentation")
.value_name("tab|space")
.default_value("tab")
.validator(|value| IndentStyle::from_str(value).map(|_| ())),
@@ -24,7 +24,7 @@ pub fn run_cli() {
.arg(
Arg::new("indent_size")
.long("indent-size")
- .about("The size of the indent.")
+ .help("The size of the indent.")
.value_name("NUMBER")
.default_value("2")
.validator(|value| {
@@ -35,7 +35,7 @@ pub fn run_cli() {
)
.arg(
Arg::new("input")
- .about("File to format")
+ .help("File to format")
.required(true)
.validator(|value| {
let path = PathBuf::from(&value);
@@ -45,17 +45,12 @@ pub fn run_cli() {
Ok(())
}),
),
- )
- .try_get_matches();
- let subcommand_matches = match &matches {
- Ok(r) => r.subcommand(),
- Err(err) => err.exit(),
- };
+ );
- let app = create_app();
+ let rome_app = create_app();
- match subcommand_matches {
- Some(("format", matches)) => {
+ match cli_app.get_matches().subcommand().unwrap() {
+ ("format", matches) => {
let size = matches.value_of("indent_size");
let style = matches.value_of("indent_style");
let input = matches.value_of("input").unwrap();
@@ -70,14 +65,9 @@ pub fn run_cli() {
})
.unwrap_or_default();
- let mut file = RomePath::new(input).deduce_handler(&app);
+ let mut file = RomePath::new(input).deduce_handler(&rome_app);
format_file_and_save(&mut file, FormatOptions::new(options));
}
- // Thanks to the settings AppSettings::SubcommandRequiredElseHelp we should not be there
- _ => clap::Error::with_description(
- "Sub command not found".to_string(),
- clap::ErrorKind::InvalidSubcommand,
- )
- .exit(),
+ _ => unreachable!("clap should ensure we don't get here"),
}
}

chore(rome_cli): Update to clap@3.0.9 (#1958)