summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/fmt.yml26
-rw-r--r--.rustfmt.toml5
-rw-r--r--Makefile12
-rw-r--r--src/main.rs12
-rw-r--r--src/remapper.rs2
5 files changed, 49 insertions, 8 deletions
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;