From a0e636635f0d8feb23ee377be7987ab34edec35e Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sun, 9 Jun 2024 05:45:23 -0700 Subject: add in my preferred rustfmt options --- .github/workflows/fmt.yml | 26 ++++++++++++++++++++++++++ .rustfmt.toml | 5 +++++ Makefile | 12 ++++++++++++ src/main.rs | 12 +++++------- src/remapper.rs | 2 +- 5 files changed, 49 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/fmt.yml create mode 100644 .rustfmt.toml create mode 100644 Makefile diff --git a/.github/workflows/fmt.yml b/.github/workflows/fmt.yml new file mode 100644 index 0000000..40b1738 --- /dev/null +++ b/.github/workflows/fmt.yml @@ -0,0 +1,26 @@ +name: fmt + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: "Install Rust" + uses: dtolnay/rust-toolchain@nightly + with: + components: rustfmt + - name: Check formatting + run: | + source $HOME/.cargo/env + cargo +nightly fmt --all -- --check + + diff --git a/.rustfmt.toml b/.rustfmt.toml new file mode 100644 index 0000000..f735ae8 --- /dev/null +++ b/.rustfmt.toml @@ -0,0 +1,5 @@ +# Please keep these in alphabetical order. +# https://github.com/rust-lang/rustfmt/issues/3149 +edition = "2018" +imports_granularity = "Module" +tab_spaces = 4 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e1196b0 --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +.PHONY: all fmt check test + +all: check + +test: + cargo nextest run + +check: + cargo check + +fmt: + cargo +nightly fmt diff --git a/src/main.rs b/src/main.rs index 0dd63de..1018aca 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,9 @@ use crate::mapping::*; use crate::remapper::*; use anyhow::{Context, Result}; +use clap::Parser; use std::path::PathBuf; use std::time::Duration; -use clap::Parser; mod deviceinfo; mod mapping; @@ -11,11 +11,7 @@ mod remapper; /// Remap libinput evdev keyboard inputs #[derive(Debug, Parser)] -#[command( - name = "evremap", - about, - author = "Wez Furlong" -)] +#[command(name = "evremap", about, author = "Wez Furlong")] enum Opt { /// Rather than running the remapper, list currently available devices. /// This is helpful to check their names when setting up the initial @@ -57,7 +53,9 @@ pub fn list_keys() -> Result<()> { fn setup_logger() { let mut builder = env_logger::Builder::new(); builder.filter_level(log::LevelFilter::Info); - let env = env_logger::Env::new().filter("EVREMAP_LOG").write_style("EVREMAP_LOG_STYLE"); + let env = env_logger::Env::new() + .filter("EVREMAP_LOG") + .write_style("EVREMAP_LOG_STYLE"); builder.parse_env(env); builder.init(); } diff --git a/src/remapper.rs b/src/remapper.rs index 5803ae4..c4bc194 100644 --- a/src/remapper.rs +++ b/src/remapper.rs @@ -1,6 +1,6 @@ use crate::mapping::*; use anyhow::*; -use evdev_rs::{DeviceWrapper, Device, GrabMode, InputEvent, ReadFlag, TimeVal, UInputDevice}; +use evdev_rs::{Device, DeviceWrapper, GrabMode, InputEvent, ReadFlag, TimeVal, UInputDevice}; use std::cmp::Ordering; use std::collections::{HashMap, HashSet}; use std::path::Path; -- cgit v1.2.3