mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-19 14:25:18 +01:00
xtask: Add format and format-check
This commit is contained in:
parent
0fac174936
commit
18c843b550
2 changed files with 60 additions and 1 deletions
|
|
@ -136,6 +136,12 @@ enum Commands {
|
|||
/// Check all packages
|
||||
Check(Package),
|
||||
|
||||
/// Check formatting
|
||||
FormatCheck(Package),
|
||||
|
||||
/// Format code
|
||||
Format(Package),
|
||||
|
||||
/// Run clippy
|
||||
Clippy(Package),
|
||||
}
|
||||
|
|
@ -360,6 +366,16 @@ fn main() -> anyhow::Result<()> {
|
|||
info!("Running clippy on backend: {backend:?}");
|
||||
cargo_clippy(&cargoarg, &args, backend)?;
|
||||
}
|
||||
Commands::FormatCheck(args) => {
|
||||
info!("Running cargo fmt: {args:?}");
|
||||
let check_only = true;
|
||||
cargo_format(&cargoarg, &args, check_only)?;
|
||||
}
|
||||
Commands::Format(args) => {
|
||||
info!("Running cargo fmt --check: {args:?}");
|
||||
let check_only = false;
|
||||
cargo_format(&cargoarg, &args, check_only)?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
@ -421,6 +437,22 @@ fn cargo_clippy(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn cargo_format(
|
||||
cargoarg: &Option<&str>,
|
||||
package: &Package,
|
||||
check_only: bool,
|
||||
) -> anyhow::Result<()> {
|
||||
command_parser(
|
||||
&CargoCommand::Format {
|
||||
cargoarg,
|
||||
package: package_filter(package),
|
||||
check_only,
|
||||
},
|
||||
false,
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn run_test(
|
||||
cargoarg: &Option<&str>,
|
||||
backend: Backends,
|
||||
|
|
@ -621,6 +653,7 @@ fn command_parser(command: &CargoCommand, overwrite: bool) -> anyhow::Result<()>
|
|||
| CargoCommand::Build { .. }
|
||||
| CargoCommand::Check { .. }
|
||||
| CargoCommand::Clippy { .. }
|
||||
| CargoCommand::Format { .. }
|
||||
| CargoCommand::ExampleSize { .. } => {
|
||||
let cargo_result = run_command(command)?;
|
||||
if let Some(exit_code) = cargo_result.exit_status.code() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue