diff --git a/Cargo.lock b/Cargo.lock index f25d3963755..8757b922a8e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -152,18 +152,18 @@ checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" [[package]] name = "bpaf" -version = "0.8.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ae5e130595d17ed4f7061317c2792ba94dc7754de93012c6d4c7191eb5d6c4b" +checksum = "72974597bfc83173d714c0fc785a8ab64ca0f0896cb72b05f2f4c5e682543871" dependencies = [ "bpaf_derive", ] [[package]] name = "bpaf_derive" -version = "0.4.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29a7fca07923e14266ed2107f9fa592a6d4895afe2e10242ffeeda56f6009314" +checksum = "f6b7be5dcfd7bb931b9932e689c69a9b9f50a46cf0b588c90ed73ec28e8e0bf4" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index cf5feeef91e..8c24f0b470b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,6 +28,7 @@ inherits = "release" rome_analyze = { path = "./crates/rome_analyze" } rome_aria = { path = "./crates/rome_aria" } rome_aria_metadata = { path = "./crates/rome_aria_metadata" } +rome_cli = { path = "./crates/rome_cli" } rome_console = { version = "0.0.1", path = "./crates/rome_console" } rome_control_flow = { path = "./crates/rome_control_flow" } rome_css_syntax = { path = "./crates/rome_css_syntax" } @@ -63,7 +64,7 @@ tests_macros = { path = "./crates/tests_macros" } # Crates needed in the workspace bitflags = "2.3.1" -bpaf = { version = "0.8.0", features = ["derive"] } +bpaf = { version = "0.9.1", features = ["derive"] } countme = "3.0.1" dashmap = "5.4.0" indexmap = "1.9.3" diff --git a/crates/rome_cli/src/commands/mod.rs b/crates/rome_cli/src/commands/mod.rs index 4bd9269285f..828c4042831 100644 --- a/crates/rome_cli/src/commands/mod.rs +++ b/crates/rome_cli/src/commands/mod.rs @@ -1,6 +1,6 @@ use crate::cli_options::{cli_options, CliOptions, ColorsArg}; use crate::VERSION; -use bpaf::{Bpaf, OptionParser}; +use bpaf::Bpaf; use rome_service::configuration::vcs::VcsConfiguration; use rome_service::configuration::{ configuration, files_configuration, formatter_configuration, javascript::javascript_formatter, @@ -21,6 +21,9 @@ pub(crate) mod version; #[derive(Debug, Clone, Bpaf)] #[bpaf(options, version(VERSION))] +/// Rome CLI +/// +/// Rome official CLI. Use it to check the health of your project or run it to check single files. pub enum RomeCommand { /// Shows the Rome version information and quit #[bpaf(command)] @@ -232,11 +235,3 @@ impl RomeCommand { } } } - -pub fn parse_command() -> OptionParser { - rome_command() - .header("Rome CLI") - .usage("rome COMMAND [ARG]") - .version(VERSION) - .descr("Rome official CLI. Use it to check the health of your project or run ti to check single files!") -} diff --git a/crates/rome_cli/src/lib.rs b/crates/rome_cli/src/lib.rs index 237a724576b..33b86e3a7fc 100644 --- a/crates/rome_cli/src/lib.rs +++ b/crates/rome_cli/src/lib.rs @@ -27,7 +27,7 @@ use crate::commands::check::CheckCommandPayload; use crate::commands::ci::CiCommandPayload; use crate::commands::format::FormatCommandPayload; use crate::commands::lint::LintCommandPayload; -pub use crate::commands::{parse_command, RomeCommand}; +pub use crate::commands::{rome_command, RomeCommand}; pub use diagnostics::CliDiagnostic; pub(crate) use execute::{execute_mode, Execution, TraversalMode}; pub use panic::setup_panic_handler; diff --git a/crates/rome_cli/src/main.rs b/crates/rome_cli/src/main.rs index 590d300c608..eef82c4d4f1 100644 --- a/crates/rome_cli/src/main.rs +++ b/crates/rome_cli/src/main.rs @@ -6,7 +6,7 @@ use bpaf::{Args, ParseFailure}; use rome_cli::{ - open_transport, parse_command, setup_panic_handler, to_color_mode, CliDiagnostic, CliSession, + open_transport, rome_command, setup_panic_handler, to_color_mode, CliDiagnostic, CliSession, RomeCommand, }; use rome_console::{markup, ConsoleExt, EnvConsole}; @@ -28,7 +28,7 @@ fn main() -> ExitCode { set_bottom_frame(main as usize); let mut console = EnvConsole::default(); - let command = parse_command().run_inner(Args::current_args()); + let command = rome_command().run_inner(Args::current_args()); match command { Ok(command) => { let color_mode = to_color_mode(command.get_color()); @@ -47,9 +47,9 @@ fn main() -> ExitCode { } } Err(failure) => { - return if let ParseFailure::Stdout(help) = &failure { - console.log(markup! {{help}}); - ExitCode::SUCCESS + return if let ParseFailure::Stdout(help, _) = &failure { + console.log(markup! {{help.to_string()}}); + ExitCode::FAILURE } else { let diagnostic = CliDiagnostic::parse_error_bpaf(failure); console.error(markup! { {PrintDiagnostic::simple(&diagnostic)}}); diff --git a/crates/rome_cli/tests/cases/config_extends.rs b/crates/rome_cli/tests/cases/config_extends.rs index 3082291132d..6bf1074d2aa 100644 --- a/crates/rome_cli/tests/cases/config_extends.rs +++ b/crates/rome_cli/tests/cases/config_extends.rs @@ -30,7 +30,7 @@ fn extends_config_ok_formatter_no_linter() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), test_file.as_os_str().to_str().unwrap()]), + Args::from([("check"), test_file.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -78,7 +78,7 @@ fn extends_config_ok_linter_not_formatter() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), test_file.as_os_str().to_str().unwrap()]), + Args::from([("check"), test_file.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -116,7 +116,7 @@ fn extends_should_raise_an_error_for_unresolved_configuration() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), test_file.as_os_str().to_str().unwrap()]), + Args::from([("check"), test_file.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -154,11 +154,14 @@ fn extends_should_raise_an_error_for_unresolved_configuration_and_show_verbose() let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("check"), - "--verbose", - test_file.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("check"), + "--verbose", + test_file.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -196,11 +199,14 @@ fn extends_resolves_when_using_config_path() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("check"), - "--config-path=config/", - test_file.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("check"), + "--config-path=config/", + test_file.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); diff --git a/crates/rome_cli/tests/commands/check.rs b/crates/rome_cli/tests/commands/check.rs index 58812d6243f..e6618817d3b 100644 --- a/crates/rome_cli/tests/commands/check.rs +++ b/crates/rome_cli/tests/commands/check.rs @@ -64,7 +64,7 @@ fn check_help() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), "--help"]), + Args::from([("check"), "--help"].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -89,7 +89,7 @@ fn ok() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("check"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -106,7 +106,7 @@ fn ok_read_only() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("check"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -123,7 +123,7 @@ fn parse_error() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("check"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -147,7 +147,7 @@ fn lint_error() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("check"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -171,7 +171,7 @@ fn maximum_diagnostics() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("check"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -217,11 +217,14 @@ fn apply_ok() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("check"), - ("--apply"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("check"), + ("--apply"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -254,11 +257,14 @@ fn apply_noop() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("check"), - ("--apply"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("check"), + ("--apply"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -283,12 +289,15 @@ fn apply_suggested_error() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("check"), - ("--apply-unsafe"), - ("--apply"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("check"), + ("--apply-unsafe"), + ("--apply"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -313,11 +322,14 @@ fn apply_suggested() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("check"), - ("--apply-unsafe"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("check"), + ("--apply-unsafe"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -365,12 +377,15 @@ function f() {\n\targuments;\n} let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("check"), - ("--apply-unsafe"), - test1.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("check"), + ("--apply-unsafe"), + test1.as_os_str().to_str().unwrap(), + test2.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -420,11 +435,14 @@ fn no_lint_if_linter_is_disabled_when_run_apply() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("check"), - ("--apply"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("check"), + ("--apply"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -460,7 +478,7 @@ fn no_lint_if_linter_is_disabled() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("check"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -496,11 +514,14 @@ fn should_disable_a_rule() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("check"), - ("--apply"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("check"), + ("--apply"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -539,11 +560,14 @@ fn should_disable_a_rule_group() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("check"), - ("--apply"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("check"), + ("--apply"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -581,7 +605,7 @@ fn downgrade_severity() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("check"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); println!("{console:?}"); @@ -627,7 +651,7 @@ fn upgrade_severity() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("check"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -672,11 +696,14 @@ fn no_lint_when_file_is_ignored() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("check"), - ("--apply"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("check"), + ("--apply"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -715,12 +742,15 @@ fn no_lint_if_files_are_listed_in_ignore_option() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("check"), - ("--apply"), - file_path_test1.as_os_str().to_str().unwrap(), - file_path_test2.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("check"), + ("--apply"), + file_path_test1.as_os_str().to_str().unwrap(), + file_path_test2.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -796,7 +826,7 @@ fn fs_error_dereferenced_symlink() { let result = run_cli( DynRef::Owned(Box::new(OsFileSystem)), &mut console, - Args::from(&[("check"), root_path.display().to_string().as_str()]), + Args::from([("check"), root_path.display().to_string().as_str()].as_slice()), ); remove_dir_all(root_path).unwrap(); @@ -851,7 +881,7 @@ fn fs_error_infinite_symlink_exapansion() { let result = run_cli( DynRef::Owned(Box::new(OsFileSystem)), &mut console, - Args::from(&[("check"), (root_path.display().to_string().as_str())]), + Args::from([("check"), (root_path.display().to_string().as_str())].as_slice()), ); remove_dir_all(root_path).unwrap(); @@ -878,11 +908,14 @@ fn fs_error_read_only() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("check"), - ("--apply"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("check"), + ("--apply"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -909,7 +942,7 @@ fn fs_error_unknown() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), ("prefix")]), + Args::from([("check"), ("prefix")].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1014,13 +1047,16 @@ fn fs_files_ignore_symlink() { let result = run_cli( DynRef::Owned(Box::new(OsFileSystem)), &mut console, - Args::from(&[ - ("check"), - ("--config-path"), - (root_path.display().to_string().as_str()), - ("--apply-unsafe"), - (src_path.display().to_string().as_str()), - ]), + Args::from( + [ + ("check"), + ("--config-path"), + (root_path.display().to_string().as_str()), + ("--apply-unsafe"), + (src_path.display().to_string().as_str()), + ] + .as_slice(), + ), ); remove_dir_all(root_path).unwrap(); @@ -1047,7 +1083,7 @@ fn file_too_large() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("check"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1077,7 +1113,7 @@ fn file_too_large_config_limit() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("check"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1102,11 +1138,14 @@ fn file_too_large_cli_limit() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("check"), - ("--files-max-size=16"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("check"), + ("--files-max-size=16"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1131,11 +1170,14 @@ fn files_max_size_parse_error() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("check"), - ("--files-max-size=-1"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("check"), + ("--files-max-size=-1"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1163,7 +1205,7 @@ fn max_diagnostics_default() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), ("src")]), + Args::from([("check"), ("src")].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1213,12 +1255,15 @@ fn max_diagnostics() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("check"), - ("--max-diagnostics"), - ("10"), - Path::new("src").as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("check"), + ("--max-diagnostics"), + ("10"), + Path::new("src").as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1264,7 +1309,7 @@ fn no_supported_file_found() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), "."]), + Args::from([("check"), "."].as_slice()), ); eprintln!("{:?}", console.out_buffer); @@ -1293,7 +1338,7 @@ a == b;", let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("check"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1318,11 +1363,14 @@ fn print_verbose() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("check"), - ("--verbose"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("check"), + ("--verbose"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1347,7 +1395,7 @@ fn unsupported_file() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("check"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1371,7 +1419,7 @@ fn suppression_syntax_error() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("check"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1399,7 +1447,7 @@ fn config_recommended_group() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("check"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); assert_cli_snapshot(SnapshotPayload::new( @@ -1422,7 +1470,7 @@ fn nursery_unstable() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("check"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1457,11 +1505,14 @@ import { bar, foom, lorem } from "foo"; let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("check"), - ("--apply-unsafe"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("check"), + ("--apply-unsafe"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -1506,7 +1557,7 @@ import * as something from "../something"; let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("check"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1551,11 +1602,14 @@ import * as something from "../something"; let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("check"), - ("--apply"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("check"), + ("--apply"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1600,11 +1654,14 @@ import * as something from "../something"; let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("check"), - ("--apply-unsafe"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("check"), + ("--apply-unsafe"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -1650,7 +1707,7 @@ fn all_rules() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("check"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1698,7 +1755,7 @@ fn top_level_all_down_level_not_all() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("check"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1746,7 +1803,7 @@ fn top_level_not_all_down_level_all() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("check"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1783,7 +1840,7 @@ fn ignore_configured_globals() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("check"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1838,11 +1895,14 @@ file2.js let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("check"), - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("check"), + file_path1.as_os_str().to_str().unwrap(), + file_path2.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1899,12 +1959,15 @@ fn ignore_vcs_os_independent_parse() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("check"), - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), - file_path3.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("check"), + file_path1.as_os_str().to_str().unwrap(), + file_path2.as_os_str().to_str().unwrap(), + file_path3.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1947,15 +2010,18 @@ file2.js let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("check"), - ("--vcs-enabled=true"), - ("--vcs-client-kind=git"), - ("--vcs-use-ignore-file=true"), - ("--vcs-root=."), - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("check"), + ("--vcs-enabled=true"), + ("--vcs-client-kind=git"), + ("--vcs-use-ignore-file=true"), + ("--vcs-root=."), + file_path1.as_os_str().to_str().unwrap(), + file_path2.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1981,7 +2047,7 @@ fn check_stdin_apply_successfully() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), "--apply", ("--stdin-file-path"), ("mock.js")]), + Args::from([("check"), "--apply", ("--stdin-file-path"), ("mock.js")].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -2019,13 +2085,16 @@ fn check_stdin_apply_unsafe_successfully() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("check"), - "--organize-imports-enabled=true", - "--apply-unsafe", - ("--stdin-file-path"), - ("mock.js"), - ]), + Args::from( + [ + ("check"), + "--organize-imports-enabled=true", + "--apply-unsafe", + ("--stdin-file-path"), + ("mock.js"), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -2066,15 +2135,18 @@ fn check_stdin_apply_unsafe_only_organize_imports() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("check"), - "--organize-imports-enabled=true", - "--linter-enabled=false", - "--formatter-enabled=false", - "--apply-unsafe", - ("--stdin-file-path"), - ("mock.js"), - ]), + Args::from( + [ + ("check"), + "--organize-imports-enabled=true", + "--linter-enabled=false", + "--formatter-enabled=false", + "--apply-unsafe", + ("--stdin-file-path"), + ("mock.js"), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -2131,7 +2203,7 @@ fn should_apply_correct_file_source() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("check"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -2165,11 +2237,14 @@ fn apply_unsafe_no_assign_in_expression() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("check"), - file_path.as_os_str().to_str().unwrap(), - ("--apply-unsafe"), - ]), + Args::from( + [ + ("check"), + file_path.as_os_str().to_str().unwrap(), + ("--apply-unsafe"), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -2227,7 +2302,7 @@ fn should_not_enable_all_recommended_rules() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("check"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -2277,7 +2352,7 @@ array.map((sentence) => sentence.split(" ")).flat(); let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("check"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -2330,7 +2405,7 @@ if (true) { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("check"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -2358,11 +2433,14 @@ fn apply_bogus_argument() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("check"), - file_path.as_os_str().to_str().unwrap(), - ("--apply-unsafe"), - ]), + Args::from( + [ + ("check"), + file_path.as_os_str().to_str().unwrap(), + ("--apply-unsafe"), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -2390,12 +2468,15 @@ fn ignores_unknown_file() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("check"), - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), - "--files-ignore-unknown=true", - ]), + Args::from( + [ + ("check"), + file_path1.as_os_str().to_str().unwrap(), + file_path2.as_os_str().to_str().unwrap(), + "--files-ignore-unknown=true", + ] + .as_slice(), + ), ); assert_cli_snapshot(SnapshotPayload::new( @@ -2436,7 +2517,7 @@ fn check_json_files() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), file_path1.as_os_str().to_str().unwrap()]), + Args::from([("check"), file_path1.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -2458,7 +2539,7 @@ fn doesnt_error_if_no_files_were_processed() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), "--no-errors-on-unmatched", ("file.js")]), + Args::from([("check"), "--no-errors-on-unmatched", ("file.js")].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); diff --git a/crates/rome_cli/tests/commands/ci.rs b/crates/rome_cli/tests/commands/ci.rs index 0e5372684a7..24e4fd7a41b 100644 --- a/crates/rome_cli/tests/commands/ci.rs +++ b/crates/rome_cli/tests/commands/ci.rs @@ -36,7 +36,7 @@ fn ci_help() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("ci"), "--help"]), + Args::from([("ci"), "--help"].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -61,7 +61,7 @@ fn ok() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("ci"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("ci"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -102,7 +102,7 @@ fn formatting_error() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("ci"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("ci"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -127,7 +127,7 @@ fn ci_parse_error() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("ci"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("ci"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -151,7 +151,7 @@ fn ci_lint_error() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("ci"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("ci"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -182,7 +182,7 @@ fn ci_does_not_run_formatter() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("ci"), input_file.as_os_str().to_str().unwrap()]), + Args::from([("ci"), input_file.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -218,11 +218,14 @@ fn ci_does_not_run_formatter_via_cli() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("ci"), - ("--formatter-enabled=false"), - input_file.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("ci"), + ("--formatter-enabled=false"), + input_file.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -263,7 +266,7 @@ fn ci_does_not_run_linter() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("ci"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("ci"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -299,11 +302,14 @@ fn ci_does_not_run_linter_via_cli() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("ci"), - ("--linter-enabled=false"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("ci"), + ("--linter-enabled=false"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -343,11 +349,14 @@ import * as something from "../something"; let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("ci"), - ("--organize-imports-enabled=false"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("ci"), + ("--organize-imports-enabled=false"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); // assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -386,13 +395,16 @@ fn ci_errors_for_all_disabled_checks() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("ci"), - ("--linter-enabled=false"), - ("--formatter-enabled=false"), - ("--organize-imports-enabled=false"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("ci"), + ("--linter-enabled=false"), + ("--formatter-enabled=false"), + ("--organize-imports-enabled=false"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -428,7 +440,7 @@ fn file_too_large() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("ci"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("ci"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -458,7 +470,7 @@ fn file_too_large_config_limit() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("ci"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("ci"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -483,11 +495,14 @@ fn file_too_large_cli_limit() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("ci"), - ("--files-max-size=16"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("ci"), + ("--files-max-size=16"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -512,11 +527,14 @@ fn files_max_size_parse_error() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("ci"), - ("--files-max-size=-1"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("ci"), + ("--files-max-size=-1"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -544,7 +562,7 @@ fn ci_runs_linter_not_formatter_issue_3495() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("ci"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("ci"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -580,7 +598,7 @@ fn max_diagnostics_default() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("ci"), ("src")]), + Args::from([("ci"), ("src")].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -635,7 +653,7 @@ fn max_diagnostics() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("ci"), ("--max-diagnostics"), ("10"), ("src")]), + Args::from([("ci"), ("--max-diagnostics"), ("10"), ("src")].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -688,11 +706,14 @@ fn print_verbose() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("ci"), - ("--verbose"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("ci"), + ("--verbose"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -740,7 +761,7 @@ something( ) let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("ci"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("ci"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -804,11 +825,14 @@ file2.js let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("ci"), - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("ci"), + file_path1.as_os_str().to_str().unwrap(), + file_path2.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -854,15 +878,18 @@ file2.js let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("ci"), - ("--vcs-enabled=true"), - ("--vcs-client-kind=git"), - ("--vcs-use-ignore-file=true"), - ("--vcs-root=."), - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("ci"), + ("--vcs-enabled=true"), + ("--vcs-client-kind=git"), + ("--vcs-use-ignore-file=true"), + ("--vcs-root=."), + file_path1.as_os_str().to_str().unwrap(), + file_path2.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -890,12 +917,15 @@ fn ignores_unknown_file() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("ci"), - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), - "--files-ignore-unknown=true", - ]), + Args::from( + [ + ("ci"), + file_path1.as_os_str().to_str().unwrap(), + file_path2.as_os_str().to_str().unwrap(), + "--files-ignore-unknown=true", + ] + .as_slice(), + ), ); assert_cli_snapshot(SnapshotPayload::new( @@ -915,7 +945,7 @@ fn doesnt_error_if_no_files_were_processed() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("ci"), "--no-errors-on-unmatched", ("file.js")]), + Args::from([("ci"), "--no-errors-on-unmatched", ("file.js")].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); diff --git a/crates/rome_cli/tests/commands/format.rs b/crates/rome_cli/tests/commands/format.rs index bb5eda0690e..d05b95b80ca 100644 --- a/crates/rome_cli/tests/commands/format.rs +++ b/crates/rome_cli/tests/commands/format.rs @@ -81,7 +81,7 @@ fn format_help() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("format"), "--help"]), + Args::from([("format"), "--help"].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -106,7 +106,7 @@ fn print() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("format"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("format"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -142,11 +142,14 @@ fn write() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("format"), - ("--write"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("format"), + ("--write"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -190,7 +193,7 @@ fn write_only_files_in_correct_base() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("format"), ("--write"), ("./src")]), + Args::from([("format"), ("--write"), ("./src")].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -236,7 +239,7 @@ fn lint_warning() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("format"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("format"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -290,16 +293,19 @@ fn custom_config_file_path() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("format"), - format!( - "--config-path={}", - config_path.display().to_string().as_str() - ) - .as_str(), - ("--write"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("format"), + format!( + "--config-path={}", + config_path.display().to_string().as_str() + ) + .as_str(), + ("--write"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -339,13 +345,16 @@ fn invalid_config_file_path() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("format"), - ("--config-path"), - (config_path.display().to_string().as_str()), - ("--write"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("format"), + ("--config-path"), + (config_path.display().to_string().as_str()), + ("--write"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -370,17 +379,20 @@ fn applies_custom_configuration() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("format"), - ("--line-width"), - ("10"), - ("--indent-style"), - ("space"), - ("--indent-size"), - ("8"), - ("--write"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("format"), + ("--line-width"), + ("10"), + ("--indent-style"), + ("space"), + ("--indent-size"), + ("8"), + ("--write"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -419,17 +431,20 @@ fn applies_custom_configuration_over_config_file() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("format"), - ("--line-width"), - ("10"), - ("--indent-style"), - ("space"), - ("--indent-size"), - ("8"), - ("--write"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("format"), + ("--line-width"), + ("10"), + ("--indent-style"), + ("space"), + ("--indent-size"), + ("8"), + ("--write"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -468,12 +483,15 @@ fn applies_custom_configuration_over_config_file_issue_3175_v1() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("format"), - ("--quote-style"), - ("single"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("format"), + ("--quote-style"), + ("single"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -517,12 +535,15 @@ fn applies_custom_configuration_over_config_file_issue_3175_v2() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("format"), - ("--indent-style"), - ("space"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("format"), + ("--indent-style"), + ("space"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -558,15 +579,18 @@ fn applies_custom_jsx_quote_style() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("format"), - ("--jsx-quote-style"), - ("single"), - ("--quote-properties"), - ("preserve"), - ("--write"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("format"), + ("--jsx-quote-style"), + ("single"), + ("--quote-properties"), + ("preserve"), + ("--write"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -602,15 +626,18 @@ fn applies_custom_quote_style() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("format"), - ("--quote-style"), - ("single"), - ("--quote-properties"), - ("preserve"), - ("--write"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("format"), + ("--quote-style"), + ("single"), + ("--quote-properties"), + ("preserve"), + ("--write"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -646,13 +673,16 @@ fn applies_custom_trailing_comma() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("format"), - ("--trailing-comma"), - ("none"), - ("--write"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("format"), + ("--trailing-comma"), + ("none"), + ("--write"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -685,7 +715,7 @@ fn trailing_comma_parse_errors() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("format"), ("--trailing-comma"), ("NONE"), ("file.js")]), + Args::from([("format"), ("--trailing-comma"), ("NONE"), ("file.js")].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -710,12 +740,15 @@ fn with_semicolons_options() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("format"), - ("--semicolons=as-needed"), - ("--write"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("format"), + ("--semicolons=as-needed"), + ("--write"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -748,7 +781,7 @@ fn with_invalid_semicolons_option() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("format"), ("--semicolons"), ("asneed"), ("file.js")]), + Args::from([("format"), ("--semicolons"), ("asneed"), ("file.js")].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -770,7 +803,7 @@ fn indent_style_parse_errors() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("format"), ("--indent-style"), ("invalid"), ("file.js")]), + Args::from([("format"), ("--indent-style"), ("invalid"), ("file.js")].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -792,7 +825,7 @@ fn indent_size_parse_errors_negative() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("format"), ("--indent-size=-1"), ("file.js")]), + Args::from([("format"), ("--indent-size=-1"), ("file.js")].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -814,7 +847,7 @@ fn indent_size_parse_errors_overflow() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("format"), ("--indent-size=257"), ("file.js")]), + Args::from([("format"), ("--indent-size=257"), ("file.js")].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -836,7 +869,7 @@ fn line_width_parse_errors_negative() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&["format", "--line-width=-1", "file.js"]), + Args::from(["format", "--line-width=-1", "file.js"].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -857,7 +890,7 @@ fn line_width_parse_errors_overflow() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("format"), ("--line-width"), ("321"), ("file.js")]), + Args::from([("format"), ("--line-width"), ("321"), ("file.js")].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -879,12 +912,15 @@ fn quote_properties_parse_errors_letter_case() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("format"), - ("--quote-properties"), - ("As-needed"), - ("file.js"), - ]), + Args::from( + [ + ("format"), + ("--quote-properties"), + ("As-needed"), + ("file.js"), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -911,7 +947,7 @@ fn format_with_configuration() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("format"), ("file.js"), ("--write")]), + Args::from([("format"), ("file.js"), ("--write")].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -949,7 +985,7 @@ fn format_is_disabled() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("format"), ("file.js"), ("--write")]), + Args::from([("format"), ("file.js"), ("--write")].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -986,7 +1022,7 @@ fn format_stdin_successfully() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("format"), ("--stdin-file-path"), ("mock.js")]), + Args::from([("format"), ("--stdin-file-path"), ("mock.js")].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -1019,7 +1055,7 @@ fn format_stdin_with_errors() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("format"), ("--stdin-file-path"), ("mock.js")]), + Args::from([("format"), ("--stdin-file-path"), ("mock.js")].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1048,7 +1084,7 @@ fn does_not_format_if_disabled() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("format"), ("--stdin-file-path"), ("mock.js")]), + Args::from([("format"), ("--stdin-file-path"), ("mock.js")].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -1086,7 +1122,7 @@ fn does_not_format_ignored_files() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("format"), ("test.js"), ("--write")]), + Args::from([("format"), ("test.js"), ("--write")].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1131,12 +1167,15 @@ fn does_not_format_if_files_are_listed_in_ignore_option() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("format"), - file_path_test1.as_os_str().to_str().unwrap(), - file_path_test2.as_os_str().to_str().unwrap(), - ("--write"), - ]), + Args::from( + [ + ("format"), + file_path_test1.as_os_str().to_str().unwrap(), + file_path_test2.as_os_str().to_str().unwrap(), + ("--write"), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1197,7 +1236,7 @@ fn does_not_format_ignored_directories() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("format"), ("./"), ("--write")]), + Args::from([("format"), ("./"), ("--write")].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -1243,11 +1282,14 @@ fn fs_error_read_only() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("format"), - ("--write"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("format"), + ("--write"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1275,11 +1317,14 @@ fn file_too_large() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("format"), - file_path.as_os_str().to_str().unwrap(), - ("--write"), - ]), + Args::from( + [ + ("format"), + file_path.as_os_str().to_str().unwrap(), + ("--write"), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1309,7 +1354,7 @@ fn file_too_large_config_limit() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("format"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("format"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1334,11 +1379,14 @@ fn file_too_large_cli_limit() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("format"), - ("--files-max-size=16"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("format"), + ("--files-max-size=16"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1363,11 +1411,14 @@ fn files_max_size_parse_error() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("format"), - ("--files-max-size=-1"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("format"), + ("--files-max-size=-1"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1394,7 +1445,7 @@ fn max_diagnostics_default() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("format"), ("src")]), + Args::from([("format"), ("src")].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -1447,7 +1498,7 @@ fn max_diagnostics() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("format"), ("--max-diagnostics"), ("10"), ("src")]), + Args::from([("format"), ("--max-diagnostics"), ("10"), ("src")].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -1495,7 +1546,7 @@ fn no_supported_file_found() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("format"), "."]), + Args::from([("format"), "."].as_slice()), ); eprintln!("{:?}", console.out_buffer); @@ -1520,11 +1571,14 @@ fn print_verbose() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("format"), - ("--verbose"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("format"), + ("--verbose"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -1585,12 +1639,15 @@ file2.js let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("format"), - ("--write"), - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("format"), + ("--write"), + file_path1.as_os_str().to_str().unwrap(), + file_path2.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -1639,16 +1696,19 @@ file2.js let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("format"), - ("--vcs-enabled=true"), - ("--vcs-client-kind=git"), - ("--vcs-use-ignore-file=true"), - ("--vcs-root=."), - ("--write"), - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("format"), + ("--vcs-enabled=true"), + ("--vcs-client-kind=git"), + ("--vcs-use-ignore-file=true"), + ("--vcs-root=."), + ("--write"), + file_path1.as_os_str().to_str().unwrap(), + file_path2.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -1676,12 +1736,15 @@ fn ignores_unknown_file() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("format"), - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), - "--files-ignore-unknown=true", - ]), + Args::from( + [ + ("format"), + file_path1.as_os_str().to_str().unwrap(), + file_path2.as_os_str().to_str().unwrap(), + "--files-ignore-unknown=true", + ] + .as_slice(), + ), ); assert_cli_snapshot(SnapshotPayload::new( @@ -1701,7 +1764,7 @@ fn doesnt_error_if_no_files_were_processed() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("format"), "--no-errors-on-unmatched", ("file.js")]), + Args::from([("format"), "--no-errors-on-unmatched", ("file.js")].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); diff --git a/crates/rome_cli/tests/commands/init.rs b/crates/rome_cli/tests/commands/init.rs index e93b0ed8ff3..fd217a937b1 100644 --- a/crates/rome_cli/tests/commands/init.rs +++ b/crates/rome_cli/tests/commands/init.rs @@ -17,7 +17,7 @@ fn init_help() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("init"), "--help"]), + Args::from([("init"), "--help"].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -39,7 +39,7 @@ fn creates_config_file() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("init")]), + Args::from([("init")].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -82,7 +82,7 @@ fn creates_config_file_when_rome_installed_via_package_manager() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("init")]), + Args::from([("init")].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); diff --git a/crates/rome_cli/tests/commands/lint.rs b/crates/rome_cli/tests/commands/lint.rs index 1124c314ce1..abd459f169b 100644 --- a/crates/rome_cli/tests/commands/lint.rs +++ b/crates/rome_cli/tests/commands/lint.rs @@ -59,7 +59,7 @@ fn check_help() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("lint"), "--help"]), + Args::from([("lint"), "--help"].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -84,7 +84,7 @@ fn ok() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("lint"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("lint"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -101,7 +101,7 @@ fn ok_read_only() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("lint"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("lint"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -118,7 +118,7 @@ fn parse_error() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("lint"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("lint"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -142,7 +142,7 @@ fn lint_error() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("lint"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("lint"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -166,7 +166,7 @@ fn maximum_diagnostics() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("lint"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("lint"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -211,11 +211,14 @@ fn apply_ok() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("lint"), - ("--apply"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("lint"), + ("--apply"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -248,11 +251,14 @@ fn apply_noop() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("lint"), - ("--apply"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("lint"), + ("--apply"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -277,12 +283,15 @@ fn apply_suggested_error() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("lint"), - ("--apply-unsafe"), - ("--apply"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("lint"), + ("--apply-unsafe"), + ("--apply"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -307,11 +316,14 @@ fn apply_suggested() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("lint"), - ("--apply-unsafe"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("lint"), + ("--apply-unsafe"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -359,12 +371,15 @@ function f() { arguments; } let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("lint"), - ("--apply-unsafe"), - test1.as_os_str().to_str().unwrap(), - test2.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("lint"), + ("--apply-unsafe"), + test1.as_os_str().to_str().unwrap(), + test2.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -414,11 +429,14 @@ fn no_lint_if_linter_is_disabled_when_run_apply() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("lint"), - ("--apply"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("lint"), + ("--apply"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -454,7 +472,7 @@ fn no_lint_if_linter_is_disabled() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("lint"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("lint"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -490,11 +508,14 @@ fn should_disable_a_rule() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("lint"), - ("--apply"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("lint"), + ("--apply"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -533,11 +554,14 @@ fn should_disable_a_rule_group() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("lint"), - ("--apply"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("lint"), + ("--apply"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -575,7 +599,7 @@ fn downgrade_severity() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("lint"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("lint"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); println!("{console:?}"); @@ -621,7 +645,7 @@ fn upgrade_severity() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("lint"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("lint"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -666,11 +690,14 @@ fn no_lint_when_file_is_ignored() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("lint"), - ("--apply"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("lint"), + ("--apply"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -709,12 +736,15 @@ fn no_lint_if_files_are_listed_in_ignore_option() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("lint"), - ("--apply"), - file_path_test1.as_os_str().to_str().unwrap(), - file_path_test2.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("lint"), + ("--apply"), + file_path_test1.as_os_str().to_str().unwrap(), + file_path_test2.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -790,7 +820,7 @@ fn fs_error_dereferenced_symlink() { let result = run_cli( DynRef::Owned(Box::new(OsFileSystem)), &mut console, - Args::from(&[("lint"), root_path.display().to_string().as_str()]), + Args::from([("lint"), root_path.display().to_string().as_str()].as_slice()), ); remove_dir_all(root_path).unwrap(); @@ -845,7 +875,7 @@ fn fs_error_infinite_symlink_exapansion() { let result = run_cli( DynRef::Owned(Box::new(OsFileSystem)), &mut console, - Args::from(&[("lint"), (root_path.display().to_string().as_str())]), + Args::from([("lint"), (root_path.display().to_string().as_str())].as_slice()), ); remove_dir_all(root_path).unwrap(); @@ -872,11 +902,14 @@ fn fs_error_read_only() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("lint"), - ("--apply"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("lint"), + ("--apply"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -903,7 +936,7 @@ fn fs_error_unknown() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("lint"), ("prefix")]), + Args::from([("lint"), ("prefix")].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1008,13 +1041,16 @@ fn fs_files_ignore_symlink() { let result = run_cli( DynRef::Owned(Box::new(OsFileSystem)), &mut console, - Args::from(&[ - ("lint"), - ("--config-path"), - (root_path.display().to_string().as_str()), - ("--apply-unsafe"), - (src_path.display().to_string().as_str()), - ]), + Args::from( + [ + ("lint"), + ("--config-path"), + (root_path.display().to_string().as_str()), + ("--apply-unsafe"), + (src_path.display().to_string().as_str()), + ] + .as_slice(), + ), ); remove_dir_all(root_path).unwrap(); @@ -1041,7 +1077,7 @@ fn file_too_large() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("lint"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("lint"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1071,7 +1107,7 @@ fn file_too_large_config_limit() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("lint"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("lint"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1096,11 +1132,14 @@ fn file_too_large_cli_limit() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("lint"), - ("--files-max-size=16"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("lint"), + ("--files-max-size=16"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1125,11 +1164,14 @@ fn files_max_size_parse_error() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("lint"), - ("--files-max-size=-1"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("lint"), + ("--files-max-size=-1"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1157,7 +1199,7 @@ fn max_diagnostics_default() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("lint"), ("src")]), + Args::from([("lint"), ("src")].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1205,12 +1247,15 @@ fn max_diagnostics() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("lint"), - ("--max-diagnostics"), - ("10"), - Path::new("src").as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("lint"), + ("--max-diagnostics"), + ("10"), + Path::new("src").as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1253,7 +1298,7 @@ fn no_supported_file_found() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("lint"), "."]), + Args::from([("lint"), "."].as_slice()), ); eprintln!("{:?}", console.out_buffer); @@ -1282,7 +1327,7 @@ a == b;", let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("lint"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("lint"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -1307,11 +1352,14 @@ fn print_verbose() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("lint"), - ("--verbose"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("lint"), + ("--verbose"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1336,7 +1384,7 @@ fn unsupported_file() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("lint"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("lint"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1360,7 +1408,7 @@ fn suppression_syntax_error() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("lint"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("lint"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1388,7 +1436,7 @@ fn config_recommended_group() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("lint"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("lint"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); assert_cli_snapshot(SnapshotPayload::new( @@ -1411,7 +1459,7 @@ fn nursery_unstable() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("lint"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("lint"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1445,7 +1493,7 @@ fn all_rules() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("lint"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("lint"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1493,7 +1541,7 @@ fn top_level_all_down_level_not_all() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("lint"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("lint"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -1541,7 +1589,7 @@ fn top_level_not_all_down_level_all() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("lint"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("lint"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1578,7 +1626,7 @@ fn ignore_configured_globals() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("lint"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("lint"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -1633,11 +1681,14 @@ file2.js let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("lint"), - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("lint"), + file_path1.as_os_str().to_str().unwrap(), + file_path2.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1694,12 +1745,15 @@ fn ignore_vcs_os_independent_parse() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("lint"), - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), - file_path3.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("lint"), + file_path1.as_os_str().to_str().unwrap(), + file_path2.as_os_str().to_str().unwrap(), + file_path3.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -1742,15 +1796,18 @@ file2.js let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("lint"), - ("--vcs-enabled=true"), - ("--vcs-client-kind=git"), - ("--vcs-use-ignore-file=true"), - ("--vcs-root=."), - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("lint"), + ("--vcs-enabled=true"), + ("--vcs-client-kind=git"), + ("--vcs-use-ignore-file=true"), + ("--vcs-root=."), + file_path1.as_os_str().to_str().unwrap(), + file_path2.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -1776,7 +1833,7 @@ fn check_stdin_apply_successfully() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("lint"), "--apply", ("--stdin-file-path"), ("mock.js")]), + Args::from([("lint"), "--apply", ("--stdin-file-path"), ("mock.js")].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -1813,12 +1870,15 @@ fn check_stdin_apply_unsafe_successfully() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("lint"), - "--apply-unsafe", - ("--stdin-file-path"), - ("mock.js"), - ]), + Args::from( + [ + ("lint"), + "--apply-unsafe", + ("--stdin-file-path"), + ("mock.js"), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -1873,7 +1933,7 @@ fn should_apply_correct_file_source() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("lint"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("lint"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -1907,11 +1967,14 @@ fn apply_unsafe_no_assign_in_expression() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("lint"), - file_path.as_os_str().to_str().unwrap(), - ("--apply-unsafe"), - ]), + Args::from( + [ + ("lint"), + file_path.as_os_str().to_str().unwrap(), + ("--apply-unsafe"), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -1969,7 +2032,7 @@ fn should_not_enable_all_recommended_rules() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("lint"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("lint"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -2019,7 +2082,7 @@ array.map((sentence) => sentence.split(" ")).flat(); let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("lint"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("lint"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -2072,7 +2135,7 @@ if (true) { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("lint"), file_path.as_os_str().to_str().unwrap()]), + Args::from([("lint"), file_path.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -2100,11 +2163,14 @@ fn apply_bogus_argument() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("lint"), - file_path.as_os_str().to_str().unwrap(), - ("--apply-unsafe"), - ]), + Args::from( + [ + ("lint"), + file_path.as_os_str().to_str().unwrap(), + ("--apply-unsafe"), + ] + .as_slice(), + ), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -2132,12 +2198,15 @@ fn ignores_unknown_file() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("lint"), - file_path1.as_os_str().to_str().unwrap(), - file_path2.as_os_str().to_str().unwrap(), - "--files-ignore-unknown=true", - ]), + Args::from( + [ + ("lint"), + file_path1.as_os_str().to_str().unwrap(), + file_path2.as_os_str().to_str().unwrap(), + "--files-ignore-unknown=true", + ] + .as_slice(), + ), ); assert_cli_snapshot(SnapshotPayload::new( @@ -2178,7 +2247,7 @@ fn check_json_files() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("lint"), file_path1.as_os_str().to_str().unwrap()]), + Args::from([("lint"), file_path1.as_os_str().to_str().unwrap()].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -2200,7 +2269,7 @@ fn doesnt_error_if_no_files_were_processed() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("lint"), "--no-errors-on-unmatched", ("file.js")]), + Args::from([("lint"), "--no-errors-on-unmatched", ("file.js")].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); diff --git a/crates/rome_cli/tests/commands/lsp_proxy.rs b/crates/rome_cli/tests/commands/lsp_proxy.rs index 913af0f6a41..2354ba55e22 100644 --- a/crates/rome_cli/tests/commands/lsp_proxy.rs +++ b/crates/rome_cli/tests/commands/lsp_proxy.rs @@ -13,7 +13,7 @@ fn lsp_proxy_help() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("lsp-proxy"), "--help"]), + Args::from([("lsp-proxy"), "--help"].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); diff --git a/crates/rome_cli/tests/commands/migrate.rs b/crates/rome_cli/tests/commands/migrate.rs index 260ddfb369d..c6c9abe27bf 100644 --- a/crates/rome_cli/tests/commands/migrate.rs +++ b/crates/rome_cli/tests/commands/migrate.rs @@ -14,7 +14,7 @@ fn migrate_help() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("migrate"), "--help"]), + Args::from([("migrate"), "--help"].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -41,7 +41,7 @@ fn migrate_config_up_to_date() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("migrate")]), + Args::from([("migrate")].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -72,7 +72,7 @@ fn missing_configuration_file() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("migrate")]), + Args::from([("migrate")].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); diff --git a/crates/rome_cli/tests/commands/rage.rs b/crates/rome_cli/tests/commands/rage.rs index 050e8050ebe..a0ff88e1d6e 100644 --- a/crates/rome_cli/tests/commands/rage.rs +++ b/crates/rome_cli/tests/commands/rage.rs @@ -17,7 +17,7 @@ fn ok() { let result = run_rage( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("rage")]), + Args::from([("rage")].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -47,7 +47,7 @@ fn with_configuration() { let result = run_rage( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("rage")]), + Args::from([("rage")].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -77,7 +77,7 @@ fn with_malformed_configuration() { let result = run_rage( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("rage")]), + Args::from([("rage")].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -144,7 +144,7 @@ Not most recent log file run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("rage")]), + Args::from([("rage")].as_slice()), ) }; diff --git a/crates/rome_cli/tests/commands/version.rs b/crates/rome_cli/tests/commands/version.rs index 17c318212f2..26f271255d7 100644 --- a/crates/rome_cli/tests/commands/version.rs +++ b/crates/rome_cli/tests/commands/version.rs @@ -13,7 +13,7 @@ fn ok() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("--version")]), + Args::from([("--version")].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -35,7 +35,7 @@ fn full() { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("version")]), + Args::from([("version")].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); diff --git a/crates/rome_cli/tests/main.rs b/crates/rome_cli/tests/main.rs index 18940ab92e4..9afedd10fca 100644 --- a/crates/rome_cli/tests/main.rs +++ b/crates/rome_cli/tests/main.rs @@ -10,7 +10,7 @@ use snap_test::assert_cli_snapshot; use bpaf::ParseFailure; use std::path::Path; -use rome_cli::{parse_command, CliDiagnostic, CliSession}; +use rome_cli::{rome_command, CliDiagnostic, CliSession}; use rome_console::{markup, BufferConsole, Console, ConsoleExt}; use rome_fs::{FileSystem, MemoryFileSystem}; use rome_service::{App, DynRef}; @@ -39,7 +39,7 @@ mod help { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("unknown"), ("--help")]), + Args::from([("unknown"), ("--help")].as_slice()), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -58,7 +58,7 @@ mod main { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("unknown")]), + Args::from([("unknown")].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); } @@ -71,7 +71,7 @@ mod main { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("format"), ("--unknown"), ("file.js")]), + Args::from([("format"), ("--unknown"), ("file.js")].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -85,7 +85,7 @@ mod main { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("format")]), + Args::from([("format")].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -99,7 +99,7 @@ mod main { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("format"), ("--write")]), + Args::from([("format"), ("--write")].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); } @@ -112,7 +112,7 @@ mod main { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), ("--max-diagnostics=foo")]), + Args::from([("check"), ("--max-diagnostics=foo")].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -126,7 +126,7 @@ mod main { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), ("--max-diagnostics=500")]), + Args::from([("check"), ("--max-diagnostics=500")].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -134,7 +134,7 @@ mod main { // // #[test] // fn no_colors() { - // let mut args = Args::from(&[("--colors=off")]); + // let mut args = Args::from([("--colors=off")]); // let result = color_from_arguments(&mut args); // // assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -142,7 +142,7 @@ mod main { // // #[test] // fn force_colors() { - // let mut args = Args::from(&[("--colors=force")]); + // let mut args = Args::from([("--colors=force")]); // let result = color_from_arguments(&mut args); // // assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -150,7 +150,7 @@ mod main { // // #[test] // fn invalid_colors() { - // let mut args = Args::from(&[("--colors=other")]); + // let mut args = Args::from([("--colors=other")]); // let result = color_from_arguments(&mut args); // assert!(result.is_err(), "run_cli returned {result:?}"); // } @@ -179,7 +179,7 @@ mod configuration { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("format"), ("file.js")]), + Args::from([("format"), ("file.js")].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -204,7 +204,7 @@ mod configuration { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("format"), ("file.js")]), + Args::from([("format"), ("file.js")].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -229,7 +229,7 @@ mod configuration { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), ("file.js")]), + Args::from([("check"), ("file.js")].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -254,7 +254,7 @@ mod configuration { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), ("file.js")]), + Args::from([("check"), ("file.js")].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -282,7 +282,7 @@ mod configuration { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[("check"), ("file.js")]), + Args::from([("check"), ("file.js")].as_slice()), ); assert!(result.is_err(), "run_cli returned {result:?}"); @@ -307,11 +307,14 @@ mod reporter_json { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - ("format"), - ("--json"), - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + ("format"), + ("--json"), + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); eprintln!("{:?}", console.out_buffer); @@ -351,12 +354,15 @@ mod reporter_json { let result = run_cli( DynRef::Borrowed(&mut fs), &mut console, - Args::from(&[ - "format", - "--write", - "--json", - file_path.as_os_str().to_str().unwrap(), - ]), + Args::from( + [ + "format", + "--write", + "--json", + file_path.as_os_str().to_str().unwrap(), + ] + .as_slice(), + ), ); assert!(result.is_ok(), "run_cli returned {result:?}"); @@ -416,13 +422,13 @@ pub(crate) fn run_cli<'app>( let app = App::new(fs, console, WorkspaceRef::Owned(workspace)); let mut session = CliSession { app }; - let command = parse_command().run_inner(args); + let command = rome_command().run_inner(args); match command { Ok(command) => session.run(command), Err(failure) => { - if let ParseFailure::Stdout(help) = &failure { + if let ParseFailure::Stdout(help, _) = &failure { let console = &mut session.app.console; - console.log(markup! {{help}}); + console.log(markup! {{help.to_string()}}); Ok(()) } else { Err(CliDiagnostic::parse_error_bpaf(failure)) diff --git a/crates/rome_cli/tests/snapshots/main_commands_check/check_help.snap b/crates/rome_cli/tests/snapshots/main_commands_check/check_help.snap index dfa29c3bb24..0db32081be9 100644 --- a/crates/rome_cli/tests/snapshots/main_commands_check/check_help.snap +++ b/crates/rome_cli/tests/snapshots/main_commands_check/check_help.snap @@ -7,67 +7,60 @@ expression: content ```block Run various checks on a set of files. -Usage: [--apply] [--apply-unsafe] []... +Usage: check [--apply] [--apply-unsafe] [PATH]... -Available positional items: - Single file, single path or list of paths - -Available options: - --apply Apply safe fixes, formatting - --apply-unsafe Apply safe fixes and unsafe fixes, formatting and import sorting - --formatter-enabled Allow to enable or disable the formatter check. - --linter-enabled Allow to enable or disable the linter check. - --organize-imports-enabled Allow to enable or disable the organize imports. - The configuration that is contained inside the file `rome.json` - Set of properties to integrate Rome with a VCS software. - --vcs-client-kind The kind of client. - --vcs-enabled Whether Rome should integrate itself with the VCS client - --vcs-use-ignore-file Whether Rome should use the VCS ignore file. When [true], - Rome will ignore the files specified in the ignore file. - --vcs-root The folder where Rome should check for VCS files. By default, Rome will - use the same folder where `rome.json` was found. If Rome can't find the - configuration, it will attempt to use the current working directory. If no - current working directory can't be found, Rome won't use the VCS integration, - and a diagnostic will be emitted - - The configuration of the filesystem - --files-max-size The maximum allowed size for source code files in bytes. Files - above this limit will be ignored for performance reason. Defaults to 1 MiB - --files-ignore-unknown Tells Rome to not emit diagnostics when handling files - that doesn't know +The configuration that is contained inside the file `rome.json` + --vcs-client-kind= The kind of client. + --vcs-enabled= Whether Rome should integrate itself with the VCS client + --vcs-use-ignore-file= Whether Rome should use the VCS ignore file. When [true], + Rome will ignore the files specified in the ignore file. + --vcs-root=PATH The folder where Rome should check for VCS files. By default, Rome will + use the same folder where `rome.json` was found. + If Rome can't find the configuration, it will attempt to use the current + working directory. If no current working directory can't be found, Rome + won't use the VCS integration, and a diagnostic will be emitted + --files-max-size=NUMBER The maximum allowed size for source code files in bytes. Files above + this limit will be ignored for performance reason. Defaults to 1 MiB + --files-ignore-unknown= Tells Rome to not emit diagnostics when handling files that + doesn't know + --indent-style= The indent style. + --indent-size=NUMBER The size of the indentation, 2 by default + --line-width=NUMBER What's the max width of a line. Defaults to 80. + --quote-style= The style for quotes. Defaults to double. + --jsx-quote-style= The style for JSX quotes. Defaults to double. + --quote-properties= When properties in objects are quoted. Defaults to asNeeded. + --trailing-comma= Print trailing commas wherever possible in multi-line comma-separated + syntactic structures. Defaults to "all". + --semicolons= Whether the formatter prints semicolons for all statements or + only in for statements where it is necessary because of ASI. - Options applied to the formatter - --indent-style The indent style. - --indent-size The size of the indentation, 2 by default - --line-width What's the max width of a line. Defaults to 80. +Global options applied to all commands + --colors= Set the formatting mode for markup: "off" prints everything as plain + text, "force" forces the formatting of markup using ANSI even if the console + output is determined to be incompatible + --use-server Connect to a running instance of the Rome daemon server. + --verbose Print additional verbose advices on diagnostics + --config-path=PATH Set the filesystem path to the directory of the rome.json configuration + file + --max-diagnostics=NUMBER Cap the amount of diagnostics displayed (default: 20) + --skip-errors Skip over files containing syntax errors instead of emitting an error + diagnostic. + --no-errors-on-unmatched Silence errors that would be emitted in case no files were processed + during the execution of the command. + --json Reports information using the JSON format - --quote-style The style for quotes. Defaults to double. - --jsx-quote-style The style for JSX quotes. Defaults to double. - --quote-properties When properties in objects are quoted. Defaults to - asNeeded. - --trailing-comma Print trailing commas wherever possible in multi-line - comma-separated syntactic structures. Defaults to "all". - --semicolons Whether the formatter prints semicolons for all statements - or only in for statements where it is necessary because of ASI. - - Global options applied to all commands - --colors Set the formatting mode for markup: "off" prints everything as plain - text, "force" forces the formatting of markup using ANSI even if the console - output is determined to be incompatible - --use-server Connect to a running instance of the Rome daemon server. - --verbose Print additional verbose advices on diagnostics - --config-path Set the filesystem path to the directory of the rome.json configuration - file - --max-diagnostics Cap the amount of diagnostics displayed (default: 20) - --skip-errors Skip over files containing syntax errors instead of emitting an error - diagnostic. - --no-errors-on-unmatched Silence errors that would be emitted in case no files were - processed during the execution of the command. - --json Reports information using the JSON format +Available positional items: + PATH Single file, single path or list of paths - --stdin-file-path A file name with its extension to pass when reading from standard - in, e.g. echo 'let a;' | rome check --stdin-file-path=file.js" - -h, --help Prints help information +Available options: + --apply Apply safe fixes, formatting + --apply-unsafe Apply safe fixes and unsafe fixes, formatting and import sorting + --formatter-enabled= Allow to enable or disable the formatter check. + --linter-enabled= Allow to enable or disable the linter check. + --organize-imports-enabled= Allow to enable or disable the organize imports. + --stdin-file-path=PATH A file name with its extension to pass when reading from standard in, + e.g. echo 'let a;' | rome check --stdin-file-path=file.js" + -h, --help Prints help information ``` diff --git a/crates/rome_cli/tests/snapshots/main_commands_check/files_max_size_parse_error.snap b/crates/rome_cli/tests/snapshots/main_commands_check/files_max_size_parse_error.snap index d75f14d7a31..e0c939fae1e 100644 --- a/crates/rome_cli/tests/snapshots/main_commands_check/files_max_size_parse_error.snap +++ b/crates/rome_cli/tests/snapshots/main_commands_check/files_max_size_parse_error.snap @@ -17,7 +17,7 @@ flags/invalid ━━━━━━━━━━━━━━━━━━━━━━ × Failed to parse CLI arguments. Caused by: - Couldn't parse "-1": invalid digit found in string + Couldn't parse `-1`: invalid digit found in string diff --git a/crates/rome_cli/tests/snapshots/main_commands_ci/ci_help.snap b/crates/rome_cli/tests/snapshots/main_commands_ci/ci_help.snap index 8a85101c8ce..4666a730b76 100644 --- a/crates/rome_cli/tests/snapshots/main_commands_ci/ci_help.snap +++ b/crates/rome_cli/tests/snapshots/main_commands_ci/ci_help.snap @@ -7,64 +7,57 @@ expression: content ```block Command to use in CI environments. Run various checks of a set of files. -Usage: [--formatter-enabled true|false] [--linter-enabled true|false] [--organize-imports-enabled -true|false] []... +Usage: ci [--formatter-enabled=] [--linter-enabled=] [--organize-imports-enabled +=] [PATH]... -Available positional items: - Single file, single path or list of paths - -Available options: - --formatter-enabled Allow to enable or disable the formatter check. - --linter-enabled Allow to enable or disable the linter check. - --organize-imports-enabled Allow to enable or disable the organize imports. - The configuration that is contained inside the file `rome.json` - Set of properties to integrate Rome with a VCS software. - --vcs-client-kind The kind of client. - --vcs-enabled Whether Rome should integrate itself with the VCS client - --vcs-use-ignore-file Whether Rome should use the VCS ignore file. When [true], - Rome will ignore the files specified in the ignore file. - --vcs-root The folder where Rome should check for VCS files. By default, Rome will - use the same folder where `rome.json` was found. If Rome can't find the - configuration, it will attempt to use the current working directory. If no - current working directory can't be found, Rome won't use the VCS integration, - and a diagnostic will be emitted - - The configuration of the filesystem - --files-max-size The maximum allowed size for source code files in bytes. Files - above this limit will be ignored for performance reason. Defaults to 1 MiB - --files-ignore-unknown Tells Rome to not emit diagnostics when handling files - that doesn't know +The configuration that is contained inside the file `rome.json` + --vcs-client-kind= The kind of client. + --vcs-enabled= Whether Rome should integrate itself with the VCS client + --vcs-use-ignore-file= Whether Rome should use the VCS ignore file. When [true], + Rome will ignore the files specified in the ignore file. + --vcs-root=PATH The folder where Rome should check for VCS files. By default, Rome will + use the same folder where `rome.json` was found. + If Rome can't find the configuration, it will attempt to use the current + working directory. If no current working directory can't be found, Rome + won't use the VCS integration, and a diagnostic will be emitted + --files-max-size=NUMBER The maximum allowed size for source code files in bytes. Files above + this limit will be ignored for performance reason. Defaults to 1 MiB + --files-ignore-unknown= Tells Rome to not emit diagnostics when handling files that + doesn't know + --indent-style= The indent style. + --indent-size=NUMBER The size of the indentation, 2 by default + --line-width=NUMBER What's the max width of a line. Defaults to 80. + --quote-style= The style for quotes. Defaults to double. + --jsx-quote-style= The style for JSX quotes. Defaults to double. + --quote-properties= When properties in objects are quoted. Defaults to asNeeded. + --trailing-comma= Print trailing commas wherever possible in multi-line comma-separated + syntactic structures. Defaults to "all". + --semicolons= Whether the formatter prints semicolons for all statements or + only in for statements where it is necessary because of ASI. - Options applied to the formatter - --indent-style The indent style. - --indent-size The size of the indentation, 2 by default - --line-width What's the max width of a line. Defaults to 80. +Global options applied to all commands + --colors= Set the formatting mode for markup: "off" prints everything as plain + text, "force" forces the formatting of markup using ANSI even if the console + output is determined to be incompatible + --use-server Connect to a running instance of the Rome daemon server. + --verbose Print additional verbose advices on diagnostics + --config-path=PATH Set the filesystem path to the directory of the rome.json configuration + file + --max-diagnostics=NUMBER Cap the amount of diagnostics displayed (default: 20) + --skip-errors Skip over files containing syntax errors instead of emitting an error + diagnostic. + --no-errors-on-unmatched Silence errors that would be emitted in case no files were processed + during the execution of the command. + --json Reports information using the JSON format - --quote-style The style for quotes. Defaults to double. - --jsx-quote-style The style for JSX quotes. Defaults to double. - --quote-properties When properties in objects are quoted. Defaults to - asNeeded. - --trailing-comma Print trailing commas wherever possible in multi-line - comma-separated syntactic structures. Defaults to "all". - --semicolons Whether the formatter prints semicolons for all statements - or only in for statements where it is necessary because of ASI. - - Global options applied to all commands - --colors Set the formatting mode for markup: "off" prints everything as plain - text, "force" forces the formatting of markup using ANSI even if the console - output is determined to be incompatible - --use-server Connect to a running instance of the Rome daemon server. - --verbose Print additional verbose advices on diagnostics - --config-path Set the filesystem path to the directory of the rome.json configuration - file - --max-diagnostics Cap the amount of diagnostics displayed (default: 20) - --skip-errors Skip over files containing syntax errors instead of emitting an error - diagnostic. - --no-errors-on-unmatched Silence errors that would be emitted in case no files were - processed during the execution of the command. - --json Reports information using the JSON format +Available positional items: + PATH Single file, single path or list of paths - -h, --help Prints help information +Available options: + --formatter-enabled= Allow to enable or disable the formatter check. + --linter-enabled= Allow to enable or disable the linter check. + --organize-imports-enabled= Allow to enable or disable the organize imports. + -h, --help Prints help information ``` diff --git a/crates/rome_cli/tests/snapshots/main_commands_ci/files_max_size_parse_error.snap b/crates/rome_cli/tests/snapshots/main_commands_ci/files_max_size_parse_error.snap index a685ba79d87..44f273a7c55 100644 --- a/crates/rome_cli/tests/snapshots/main_commands_ci/files_max_size_parse_error.snap +++ b/crates/rome_cli/tests/snapshots/main_commands_ci/files_max_size_parse_error.snap @@ -17,7 +17,7 @@ flags/invalid ━━━━━━━━━━━━━━━━━━━━━━ × Failed to parse CLI arguments. Caused by: - Couldn't parse "-1": invalid digit found in string + Couldn't parse `-1`: invalid digit found in string diff --git a/crates/rome_cli/tests/snapshots/main_commands_format/files_max_size_parse_error.snap b/crates/rome_cli/tests/snapshots/main_commands_format/files_max_size_parse_error.snap index 09b9c4101eb..a7a18b769fc 100644 --- a/crates/rome_cli/tests/snapshots/main_commands_format/files_max_size_parse_error.snap +++ b/crates/rome_cli/tests/snapshots/main_commands_format/files_max_size_parse_error.snap @@ -17,7 +17,7 @@ flags/invalid ━━━━━━━━━━━━━━━━━━━━━━ × Failed to parse CLI arguments. Caused by: - Couldn't parse "-1": invalid digit found in string + Couldn't parse `-1`: invalid digit found in string diff --git a/crates/rome_cli/tests/snapshots/main_commands_format/format_help.snap b/crates/rome_cli/tests/snapshots/main_commands_format/format_help.snap index 38ab14c2d5a..169ef25c4b9 100644 --- a/crates/rome_cli/tests/snapshots/main_commands_format/format_help.snap +++ b/crates/rome_cli/tests/snapshots/main_commands_format/format_help.snap @@ -7,61 +7,60 @@ expression: content ```block Run the formatter on a set of files. -Usage: [--write] []... +Usage: format [--write] [PATH]... -Available positional items: - Single file, single path or list of paths. +Options applied to the formatter + --indent-style= The indent style. + --indent-size=NUMBER The size of the indentation, 2 by default + --line-width=NUMBER What's the max width of a line. Defaults to 80. -Available options: - Options applied to the formatter - --indent-style The indent style. - --indent-size The size of the indentation, 2 by default - --line-width What's the max width of a line. Defaults to 80. +Set of properties to integrate Rome with a VCS software. + --vcs-client-kind= The kind of client. + --vcs-enabled= Whether Rome should integrate itself with the VCS client + --vcs-use-ignore-file= Whether Rome should use the VCS ignore file. When [true], + Rome will ignore the files specified in the ignore file. + --vcs-root=PATH The folder where Rome should check for VCS files. By default, Rome will + use the same folder where `rome.json` was found. + If Rome can't find the configuration, it will attempt to use the current + working directory. If no current working directory can't be found, Rome + won't use the VCS integration, and a diagnostic will be emitted - --quote-style The style for quotes. Defaults to double. - --jsx-quote-style The style for JSX quotes. Defaults to double. - --quote-properties When properties in objects are quoted. Defaults to - asNeeded. - --trailing-comma Print trailing commas wherever possible in multi-line - comma-separated syntactic structures. Defaults to "all". - --semicolons Whether the formatter prints semicolons for all statements - or only in for statements where it is necessary because of ASI. - Set of properties to integrate Rome with a VCS software. - --vcs-client-kind The kind of client. - --vcs-enabled Whether Rome should integrate itself with the VCS client - --vcs-use-ignore-file Whether Rome should use the VCS ignore file. When [true], - Rome will ignore the files specified in the ignore file. - --vcs-root The folder where Rome should check for VCS files. By default, Rome will - use the same folder where `rome.json` was found. If Rome can't find the - configuration, it will attempt to use the current working directory. If no - current working directory can't be found, Rome won't use the VCS integration, - and a diagnostic will be emitted +The configuration of the filesystem + --files-max-size=NUMBER The maximum allowed size for source code files in bytes. Files above + this limit will be ignored for performance reason. Defaults to 1 MiB + --files-ignore-unknown= Tells Rome to not emit diagnostics when handling files that + doesn't know - The configuration of the filesystem - --files-max-size The maximum allowed size for source code files in bytes. Files - above this limit will be ignored for performance reason. Defaults to 1 MiB - --files-ignore-unknown Tells Rome to not emit diagnostics when handling files - that doesn't know +Global options applied to all commands + --colors= Set the formatting mode for markup: "off" prints everything as plain + text, "force" forces the formatting of markup using ANSI even if the console + output is determined to be incompatible + --use-server Connect to a running instance of the Rome daemon server. + --verbose Print additional verbose advices on diagnostics + --config-path=PATH Set the filesystem path to the directory of the rome.json configuration + file + --max-diagnostics=NUMBER Cap the amount of diagnostics displayed (default: 20) + --skip-errors Skip over files containing syntax errors instead of emitting an error + diagnostic. + --no-errors-on-unmatched Silence errors that would be emitted in case no files were processed + during the execution of the command. + --json Reports information using the JSON format - --stdin-file-path A file name with its extension to pass when reading from standard - in, e.g. echo 'let a;' | rome format --stdin-file-path=file.js". - Global options applied to all commands - --colors Set the formatting mode for markup: "off" prints everything as plain - text, "force" forces the formatting of markup using ANSI even if the console - output is determined to be incompatible - --use-server Connect to a running instance of the Rome daemon server. - --verbose Print additional verbose advices on diagnostics - --config-path Set the filesystem path to the directory of the rome.json configuration - file - --max-diagnostics Cap the amount of diagnostics displayed (default: 20) - --skip-errors Skip over files containing syntax errors instead of emitting an error - diagnostic. - --no-errors-on-unmatched Silence errors that would be emitted in case no files were - processed during the execution of the command. - --json Reports information using the JSON format +Available positional items: + PATH Single file, single path or list of paths. - --write Writes formatted files to file system. - -h, --help Prints help information +Available options: + --quote-style= The style for quotes. Defaults to double. + --jsx-quote-style= The style for JSX quotes. Defaults to double. + --quote-properties= When properties in objects are quoted. Defaults to asNeeded. + --trailing-comma= Print trailing commas wherever possible in multi-line comma-separated + syntactic structures. Defaults to "all". + --semicolons= Whether the formatter prints semicolons for all statements or + only in for statements where it is necessary because of ASI. + --stdin-file-path=PATH A file name with its extension to pass when reading from standard in, + e.g. echo 'let a;' | rome format --stdin-file-path=file.js". + --write Writes formatted files to file system. + -h, --help Prints help information ``` diff --git a/crates/rome_cli/tests/snapshots/main_commands_format/indent_size_parse_errors_negative.snap b/crates/rome_cli/tests/snapshots/main_commands_format/indent_size_parse_errors_negative.snap index c5a092b3f6c..c38611d85b2 100644 --- a/crates/rome_cli/tests/snapshots/main_commands_format/indent_size_parse_errors_negative.snap +++ b/crates/rome_cli/tests/snapshots/main_commands_format/indent_size_parse_errors_negative.snap @@ -10,7 +10,7 @@ flags/invalid ━━━━━━━━━━━━━━━━━━━━━━ × Failed to parse CLI arguments. Caused by: - Couldn't parse "-1": invalid digit found in string + Couldn't parse `-1`: invalid digit found in string diff --git a/crates/rome_cli/tests/snapshots/main_commands_format/indent_size_parse_errors_overflow.snap b/crates/rome_cli/tests/snapshots/main_commands_format/indent_size_parse_errors_overflow.snap index 033b1736c06..4cf79cdb484 100644 --- a/crates/rome_cli/tests/snapshots/main_commands_format/indent_size_parse_errors_overflow.snap +++ b/crates/rome_cli/tests/snapshots/main_commands_format/indent_size_parse_errors_overflow.snap @@ -10,7 +10,7 @@ flags/invalid ━━━━━━━━━━━━━━━━━━━━━━ × Failed to parse CLI arguments. Caused by: - Couldn't parse "257": number too large to fit in target type + Couldn't parse `257`: number too large to fit in target type diff --git a/crates/rome_cli/tests/snapshots/main_commands_format/indent_style_parse_errors.snap b/crates/rome_cli/tests/snapshots/main_commands_format/indent_style_parse_errors.snap index b68079ba05a..c281e93fb7c 100644 --- a/crates/rome_cli/tests/snapshots/main_commands_format/indent_style_parse_errors.snap +++ b/crates/rome_cli/tests/snapshots/main_commands_format/indent_style_parse_errors.snap @@ -10,7 +10,7 @@ flags/invalid ━━━━━━━━━━━━━━━━━━━━━━ × Failed to parse CLI arguments. Caused by: - Couldn't parse "invalid": Unsupported value for this option + Couldn't parse `invalid`: Unsupported value for this option diff --git a/crates/rome_cli/tests/snapshots/main_commands_format/line_width_parse_errors_negative.snap b/crates/rome_cli/tests/snapshots/main_commands_format/line_width_parse_errors_negative.snap index c5a092b3f6c..c38611d85b2 100644 --- a/crates/rome_cli/tests/snapshots/main_commands_format/line_width_parse_errors_negative.snap +++ b/crates/rome_cli/tests/snapshots/main_commands_format/line_width_parse_errors_negative.snap @@ -10,7 +10,7 @@ flags/invalid ━━━━━━━━━━━━━━━━━━━━━━ × Failed to parse CLI arguments. Caused by: - Couldn't parse "-1": invalid digit found in string + Couldn't parse `-1`: invalid digit found in string diff --git a/crates/rome_cli/tests/snapshots/main_commands_format/line_width_parse_errors_overflow.snap b/crates/rome_cli/tests/snapshots/main_commands_format/line_width_parse_errors_overflow.snap index 9c2e57dbaf2..c0a29ea1875 100644 --- a/crates/rome_cli/tests/snapshots/main_commands_format/line_width_parse_errors_overflow.snap +++ b/crates/rome_cli/tests/snapshots/main_commands_format/line_width_parse_errors_overflow.snap @@ -10,8 +10,7 @@ flags/invalid ━━━━━━━━━━━━━━━━━━━━━━ × Failed to parse CLI arguments. Caused by: - Couldn't parse "321": The line width exceeds the maximum value (320) - + Couldn't parse `321`: The line width exceeds the maximum value (320) diff --git a/crates/rome_cli/tests/snapshots/main_commands_format/quote_properties_parse_errors_letter_case.snap b/crates/rome_cli/tests/snapshots/main_commands_format/quote_properties_parse_errors_letter_case.snap index bc18379c087..6c2de74086c 100644 --- a/crates/rome_cli/tests/snapshots/main_commands_format/quote_properties_parse_errors_letter_case.snap +++ b/crates/rome_cli/tests/snapshots/main_commands_format/quote_properties_parse_errors_letter_case.snap @@ -10,7 +10,7 @@ flags/invalid ━━━━━━━━━━━━━━━━━━━━━━ × Failed to parse CLI arguments. Caused by: - Couldn't parse "As-needed": Value not supported for QuoteProperties + Couldn't parse `As-needed`: Value not supported for QuoteProperties diff --git a/crates/rome_cli/tests/snapshots/main_commands_format/trailing_comma_parse_errors.snap b/crates/rome_cli/tests/snapshots/main_commands_format/trailing_comma_parse_errors.snap index 143bcbb7344..007a41eafa4 100644 --- a/crates/rome_cli/tests/snapshots/main_commands_format/trailing_comma_parse_errors.snap +++ b/crates/rome_cli/tests/snapshots/main_commands_format/trailing_comma_parse_errors.snap @@ -10,7 +10,7 @@ flags/invalid ━━━━━━━━━━━━━━━━━━━━━━ × Failed to parse CLI arguments. Caused by: - Couldn't parse "NONE": Value not supported for TrailingComma + Couldn't parse `NONE`: Value not supported for TrailingComma diff --git a/crates/rome_cli/tests/snapshots/main_commands_format/with_invalid_semicolons_option.snap b/crates/rome_cli/tests/snapshots/main_commands_format/with_invalid_semicolons_option.snap index 9511095ad15..aadba8e4936 100644 --- a/crates/rome_cli/tests/snapshots/main_commands_format/with_invalid_semicolons_option.snap +++ b/crates/rome_cli/tests/snapshots/main_commands_format/with_invalid_semicolons_option.snap @@ -10,7 +10,7 @@ flags/invalid ━━━━━━━━━━━━━━━━━━━━━━ × Failed to parse CLI arguments. Caused by: - Couldn't parse "asneed": Value not supported for Semicolons. Supported values are 'as-needed' and 'always'. + Couldn't parse `asneed`: Value not supported for Semicolons. Supported values are 'as-needed' and 'always'. diff --git a/crates/rome_cli/tests/snapshots/main_commands_init/init_help.snap b/crates/rome_cli/tests/snapshots/main_commands_init/init_help.snap index 53d4bd4b423..3c622e56db1 100644 --- a/crates/rome_cli/tests/snapshots/main_commands_init/init_help.snap +++ b/crates/rome_cli/tests/snapshots/main_commands_init/init_help.snap @@ -7,7 +7,7 @@ expression: content ```block Bootstraps a new rome project. Creates a configuration file with some defaults. -Usage: no parameters expected +Usage: init Available options: -h, --help Prints help information diff --git a/crates/rome_cli/tests/snapshots/main_commands_lint/check_help.snap b/crates/rome_cli/tests/snapshots/main_commands_lint/check_help.snap index 2cb880dfc56..9a4d7264074 100644 --- a/crates/rome_cli/tests/snapshots/main_commands_lint/check_help.snap +++ b/crates/rome_cli/tests/snapshots/main_commands_lint/check_help.snap @@ -7,64 +7,57 @@ expression: content ```block Run various checks on a set of files. -Usage: [--apply] [--apply-unsafe] []... +Usage: lint [--apply] [--apply-unsafe] [PATH]... -Available positional items: - Single file, single path or list of paths - -Available options: - --apply Apply safe fixes, formatting - --apply-unsafe Apply safe fixes and unsafe fixes, formatting and import sorting - The configuration that is contained inside the file `rome.json` - Set of properties to integrate Rome with a VCS software. - --vcs-client-kind The kind of client. - --vcs-enabled Whether Rome should integrate itself with the VCS client - --vcs-use-ignore-file Whether Rome should use the VCS ignore file. When [true], - Rome will ignore the files specified in the ignore file. - --vcs-root The folder where Rome should check for VCS files. By default, Rome will - use the same folder where `rome.json` was found. If Rome can't find the - configuration, it will attempt to use the current working directory. If no - current working directory can't be found, Rome won't use the VCS integration, - and a diagnostic will be emitted - - The configuration of the filesystem - --files-max-size The maximum allowed size for source code files in bytes. Files - above this limit will be ignored for performance reason. Defaults to 1 MiB - --files-ignore-unknown Tells Rome to not emit diagnostics when handling files - that doesn't know +The configuration that is contained inside the file `rome.json` + --vcs-client-kind= The kind of client. + --vcs-enabled= Whether Rome should integrate itself with the VCS client + --vcs-use-ignore-file= Whether Rome should use the VCS ignore file. When [true], + Rome will ignore the files specified in the ignore file. + --vcs-root=PATH The folder where Rome should check for VCS files. By default, Rome will + use the same folder where `rome.json` was found. + If Rome can't find the configuration, it will attempt to use the current + working directory. If no current working directory can't be found, Rome + won't use the VCS integration, and a diagnostic will be emitted + --files-max-size=NUMBER The maximum allowed size for source code files in bytes. Files above + this limit will be ignored for performance reason. Defaults to 1 MiB + --files-ignore-unknown= Tells Rome to not emit diagnostics when handling files that + doesn't know + --indent-style= The indent style. + --indent-size=NUMBER The size of the indentation, 2 by default + --line-width=NUMBER What's the max width of a line. Defaults to 80. + --quote-style= The style for quotes. Defaults to double. + --jsx-quote-style= The style for JSX quotes. Defaults to double. + --quote-properties= When properties in objects are quoted. Defaults to asNeeded. + --trailing-comma= Print trailing commas wherever possible in multi-line comma-separated + syntactic structures. Defaults to "all". + --semicolons= Whether the formatter prints semicolons for all statements or + only in for statements where it is necessary because of ASI. - Options applied to the formatter - --indent-style The indent style. - --indent-size The size of the indentation, 2 by default - --line-width What's the max width of a line. Defaults to 80. +Global options applied to all commands + --colors= Set the formatting mode for markup: "off" prints everything as plain + text, "force" forces the formatting of markup using ANSI even if the console + output is determined to be incompatible + --use-server Connect to a running instance of the Rome daemon server. + --verbose Print additional verbose advices on diagnostics + --config-path=PATH Set the filesystem path to the directory of the rome.json configuration + file + --max-diagnostics=NUMBER Cap the amount of diagnostics displayed (default: 20) + --skip-errors Skip over files containing syntax errors instead of emitting an error + diagnostic. + --no-errors-on-unmatched Silence errors that would be emitted in case no files were processed + during the execution of the command. + --json Reports information using the JSON format - --quote-style The style for quotes. Defaults to double. - --jsx-quote-style The style for JSX quotes. Defaults to double. - --quote-properties When properties in objects are quoted. Defaults to - asNeeded. - --trailing-comma Print trailing commas wherever possible in multi-line - comma-separated syntactic structures. Defaults to "all". - --semicolons Whether the formatter prints semicolons for all statements - or only in for statements where it is necessary because of ASI. - - Global options applied to all commands - --colors Set the formatting mode for markup: "off" prints everything as plain - text, "force" forces the formatting of markup using ANSI even if the console - output is determined to be incompatible - --use-server Connect to a running instance of the Rome daemon server. - --verbose Print additional verbose advices on diagnostics - --config-path Set the filesystem path to the directory of the rome.json configuration - file - --max-diagnostics Cap the amount of diagnostics displayed (default: 20) - --skip-errors Skip over files containing syntax errors instead of emitting an error - diagnostic. - --no-errors-on-unmatched Silence errors that would be emitted in case no files were - processed during the execution of the command. - --json Reports information using the JSON format +Available positional items: + PATH Single file, single path or list of paths - --stdin-file-path A file name with its extension to pass when reading from standard - in, e.g. echo 'let a;' | rome lint --stdin-file-path=file.js" - -h, --help Prints help information +Available options: + --apply Apply safe fixes, formatting + --apply-unsafe Apply safe fixes and unsafe fixes, formatting and import sorting + --stdin-file-path=PATH A file name with its extension to pass when reading from standard in, + e.g. echo 'let a;' | rome lint --stdin-file-path=file.js" + -h, --help Prints help information ``` diff --git a/crates/rome_cli/tests/snapshots/main_commands_lint/files_max_size_parse_error.snap b/crates/rome_cli/tests/snapshots/main_commands_lint/files_max_size_parse_error.snap index d75f14d7a31..e0c939fae1e 100644 --- a/crates/rome_cli/tests/snapshots/main_commands_lint/files_max_size_parse_error.snap +++ b/crates/rome_cli/tests/snapshots/main_commands_lint/files_max_size_parse_error.snap @@ -17,7 +17,7 @@ flags/invalid ━━━━━━━━━━━━━━━━━━━━━━ × Failed to parse CLI arguments. Caused by: - Couldn't parse "-1": invalid digit found in string + Couldn't parse `-1`: invalid digit found in string diff --git a/crates/rome_cli/tests/snapshots/main_commands_lsp_proxy/lsp_proxy_help.snap b/crates/rome_cli/tests/snapshots/main_commands_lsp_proxy/lsp_proxy_help.snap index 74f77f55e73..34840a7b09c 100644 --- a/crates/rome_cli/tests/snapshots/main_commands_lsp_proxy/lsp_proxy_help.snap +++ b/crates/rome_cli/tests/snapshots/main_commands_lsp_proxy/lsp_proxy_help.snap @@ -7,26 +7,26 @@ expression: content ```block Acts as a server for the Language Server Protocol over stdin/stdout -Usage: [--colors off|force] [--use-server] [--verbose] [--config-path PATH] [--max-diagnostics -NUMBER] [--skip-errors] [--no-errors-on-unmatched] +Usage: lsp-proxy [--colors=] [--use-server] [--verbose] [--config-path=PATH] [--max-diagnostics +=NUMBER] [--skip-errors] [--no-errors-on-unmatched] -Available options: - Global options applied to all commands - --colors Set the formatting mode for markup: "off" prints everything as plain - text, "force" forces the formatting of markup using ANSI even if the console - output is determined to be incompatible - --use-server Connect to a running instance of the Rome daemon server. - --verbose Print additional verbose advices on diagnostics - --config-path Set the filesystem path to the directory of the rome.json configuration - file - --max-diagnostics Cap the amount of diagnostics displayed (default: 20) - --skip-errors Skip over files containing syntax errors instead of emitting an error - diagnostic. - --no-errors-on-unmatched Silence errors that would be emitted in case no files were - processed during the execution of the command. - --json Reports information using the JSON format +Global options applied to all commands + --colors= Set the formatting mode for markup: "off" prints everything as plain + text, "force" forces the formatting of markup using ANSI even if the console + output is determined to be incompatible + --use-server Connect to a running instance of the Rome daemon server. + --verbose Print additional verbose advices on diagnostics + --config-path=PATH Set the filesystem path to the directory of the rome.json configuration + file + --max-diagnostics=NUMBER Cap the amount of diagnostics displayed (default: 20) + --skip-errors Skip over files containing syntax errors instead of emitting an error + diagnostic. + --no-errors-on-unmatched Silence errors that would be emitted in case no files were processed + during the execution of the command. + --json Reports information using the JSON format - -h, --help Prints help information +Available options: + -h, --help Prints help information ``` diff --git a/crates/rome_cli/tests/snapshots/main_commands_migrate/migrate_help.snap b/crates/rome_cli/tests/snapshots/main_commands_migrate/migrate_help.snap index 760a14c19a7..c57377fc813 100644 --- a/crates/rome_cli/tests/snapshots/main_commands_migrate/migrate_help.snap +++ b/crates/rome_cli/tests/snapshots/main_commands_migrate/migrate_help.snap @@ -7,26 +7,26 @@ expression: content ```block It updates the configuration when there are breaking changes -Usage: [--write] +Usage: migrate [--write] -Available options: - Global options applied to all commands - --colors Set the formatting mode for markup: "off" prints everything as plain - text, "force" forces the formatting of markup using ANSI even if the console - output is determined to be incompatible - --use-server Connect to a running instance of the Rome daemon server. - --verbose Print additional verbose advices on diagnostics - --config-path Set the filesystem path to the directory of the rome.json configuration - file - --max-diagnostics Cap the amount of diagnostics displayed (default: 20) - --skip-errors Skip over files containing syntax errors instead of emitting an error - diagnostic. - --no-errors-on-unmatched Silence errors that would be emitted in case no files were - processed during the execution of the command. - --json Reports information using the JSON format +Global options applied to all commands + --colors= Set the formatting mode for markup: "off" prints everything as plain + text, "force" forces the formatting of markup using ANSI even if the console + output is determined to be incompatible + --use-server Connect to a running instance of the Rome daemon server. + --verbose Print additional verbose advices on diagnostics + --config-path=PATH Set the filesystem path to the directory of the rome.json configuration + file + --max-diagnostics=NUMBER Cap the amount of diagnostics displayed (default: 20) + --skip-errors Skip over files containing syntax errors instead of emitting an error + diagnostic. + --no-errors-on-unmatched Silence errors that would be emitted in case no files were processed + during the execution of the command. + --json Reports information using the JSON format - --write Writes the new configuration file to disk - -h, --help Prints help information +Available options: + --write Writes the new configuration file to disk + -h, --help Prints help information ``` diff --git a/crates/rome_cli/tests/snapshots/main_commands_version/version_ok.snap b/crates/rome_cli/tests/snapshots/main_commands_version/version_ok.snap index ecb5753dfa3..d3cae446286 100644 --- a/crates/rome_cli/tests/snapshots/main_commands_version/version_ok.snap +++ b/crates/rome_cli/tests/snapshots/main_commands_version/version_ok.snap @@ -6,7 +6,6 @@ expression: content ```block Version: 0.0.0 - ```