Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

chore: upgrade bpaf #4659

Merged
merged 1 commit into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down Expand Up @@ -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"
Expand Down
13 changes: 4 additions & 9 deletions crates/rome_cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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)]
Expand Down Expand Up @@ -232,11 +235,3 @@ impl RomeCommand {
}
}
}

pub fn parse_command() -> OptionParser<RomeCommand> {
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!")
}
2 changes: 1 addition & 1 deletion crates/rome_cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions crates/rome_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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());
Expand All @@ -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)}});
Expand Down
32 changes: 19 additions & 13 deletions crates/rome_cli/tests/cases/config_extends.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:?}");
Expand Down Expand Up @@ -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:?}");
Expand Down Expand Up @@ -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:?}");
Expand Down Expand Up @@ -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:?}");
Expand Down Expand Up @@ -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:?}");
Expand Down
Loading
Loading