7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1 | use clap::{Args, Subcommand}; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 2 | use xshell::cmd; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 3 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 4 | use crate::{NIGHTLY, Result, sh, workspace}; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 5 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 6 | #[derive(Args)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 7 | pub struct FixupArgs { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 8 | #[clap(subcommand)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 9 | cmd: Option<FixupCommand>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 10 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 11 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 12 | #[derive(Subcommand)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 13 | enum FixupCommand { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 14 | /// Fix style |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 15 | Style, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 16 | /// Fix typos |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 17 | Typos, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 18 | /// Fix clippy lints |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 19 | Clippy, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 20 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 21 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 22 | impl FixupArgs { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 23 | pub fn run(self) -> Result<()> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 24 | let sh = sh(); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 25 | let _p = sh.push_dir(workspace::root_path()?); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 26 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 27 | match self.cmd { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 28 | Some(cmd) => match cmd { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 29 | FixupCommand::Style => fix_style(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 30 | FixupCommand::Typos => fix_typos(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 31 | FixupCommand::Clippy => fix_clippy(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 32 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 33 | None => { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 34 | fix_style()?; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 35 | fix_typos()?; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 36 | fix_clippy()?; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 37 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 38 | Ok(()) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 39 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 40 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 41 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 42 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 43 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 44 | fn fix_style() -> Result<()> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 45 | let sh = sh(); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 46 | cmd!(sh, "rustup run {NIGHTLY} cargo fmt").run()?; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 47 | Ok(()) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 48 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 49 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 50 | fn fix_typos() -> Result<()> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 51 | let sh = sh(); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 52 | // FIXME: Print install instructions if command-not-found (needs an xshell |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 53 | // change: https://github.com/matklad/xshell/issues/46) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 54 | cmd!(sh, "typos --write-changes").run()?; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 55 | Ok(()) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 56 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 57 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 58 | fn fix_clippy() -> Result<()> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 59 | let sh = sh(); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 60 | cmd!( |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 61 | sh, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 62 | "rustup run {NIGHTLY} cargo clippy --all-targets |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 63 | --fix --allow-dirty --allow-staged |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 64 | -- -D warnings " |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 65 | ) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 66 | .run()?; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 67 | cmd!( |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 68 | sh, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 69 | "rustup run {NIGHTLY} cargo clippy --workspace --all-targets |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 70 | --fix --allow-dirty --allow-staged |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 71 | --exclude matrix-sdk-crypto --exclude xtask |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 72 | --no-default-features --features rustls-tls,sso-login |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 73 | -- -D warnings" |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 74 | ) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 75 | .run()?; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 76 | cmd!( |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 77 | sh, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 78 | "rustup run {NIGHTLY} cargo clippy --all-targets -p matrix-sdk-crypto |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 79 | --allow-dirty --allow-staged --fix |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 80 | --no-default-features -- -D warnings" |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 81 | ) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 82 | .run()?; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 83 | Ok(()) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 84 | } |