Skip to content

Commit 033030c

Browse files
authored
refactor: removed unused stuff, added formatting (#15)
1 parent 0abfcf4 commit 033030c

File tree

14 files changed

+254
-106
lines changed

14 files changed

+254
-106
lines changed

.github/workflows/format.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Format and Lint
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
format:
14+
name: Format Check
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Install Rust
20+
uses: dtolnay/rust-toolchain@stable
21+
with:
22+
components: rustfmt
23+
24+
- name: Check formatting
25+
run: cargo fmt --all -- --check
26+
27+
clippy:
28+
name: Clippy
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- name: Install Rust
34+
uses: dtolnay/rust-toolchain@stable
35+
with:
36+
components: clippy
37+
38+
- name: Cache dependencies
39+
uses: actions/cache@v3
40+
with:
41+
path: |
42+
~/.cargo/registry
43+
~/.cargo/git
44+
target
45+
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
46+
47+
- name: Run Clippy
48+
run: cargo clippy --all-targets --all-features -- -D warnings

CONTRIBUTING.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,40 @@ wer/
7676

7777
## Code Guidelines
7878

79+
### Code Formatting
80+
81+
This project uses automated formatting to maintain code consistency:
82+
83+
- **rustfmt**: All code must be formatted with `rustfmt` using the project's `rustfmt.toml` configuration
84+
- **Clippy**: Code must pass all Clippy lints without warnings
85+
86+
#### Commands
87+
88+
Use these cargo commands for formatting and linting:
89+
90+
```bash
91+
# Format all code
92+
cargo fmt --all
93+
94+
# Check if code is properly formatted (without changing files)
95+
cargo fmt --all -- --check
96+
97+
# Run Clippy linter
98+
cargo clippy --all-targets --all-features -- -D warnings
99+
100+
# Run tests
101+
cargo test
102+
103+
# Build the project
104+
cargo build --release
105+
```
106+
107+
#### Automated Checks
108+
109+
- GitHub Actions automatically checks formatting and linting on all PRs
110+
- PRs must pass all formatting and lint checks before merging
111+
- Format your code before submitting to avoid CI failures
112+
79113
### Rust Style
80114

81115
- Follow [Rust API Guidelines](https://rust-lang.github.io/api-guidelines/)

Cargo.toml.bak

Lines changed: 0 additions & 19 deletions
This file was deleted.

rustfmt.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# rustfmt configuration for wer project
2+
3+
edition = "2024"
4+
max_width = 100
5+
hard_tabs = false
6+
tab_spaces = 4
7+
newline_style = "Unix"
8+
remove_nested_parens = true
9+
use_small_heuristics = "Default"

src/cli.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ use clap::Parser;
55
#[command(version = env!("CARGO_PKG_VERSION"))]
66
#[command(disable_version_flag = true)]
77
#[command(about = "Find out who last edited any file or directory in a Git repository")]
8-
#[command(long_about = r#"Find out who last edited any file or directory in a Git repository
8+
#[command(
9+
long_about = r#"Find out who last edited any file or directory in a Git repository
910
1011
SMART PATH RESOLUTION:
1112
wer automatically finds files and directories by name:
@@ -35,41 +36,42 @@ EXAMPLES:
3536
wer -b git.rs Find and show blame for src/git.rs
3637
wer -d . Show only the date of last change
3738
wer -l 3 src/ Show last 3 contributors to src/ directory
38-
wer -b -m file.py Show blame with commit messages"#)]
39+
wer -b -m file.py Show blame with commit messages"#
40+
)]
3941
#[command(arg(clap::Arg::new("version")
4042
.short('v')
4143
.long("version")
4244
.action(clap::ArgAction::Version)
4345
.help("Print version")))]
4446
pub struct Cli {
4547
/// File or directory path (searches automatically if not found in current directory)
46-
///
48+
///
4749
/// Can be just a filename (main.rs), directory name (src/), or full path.
4850
/// For absolute paths, use ~/file.txt or /full/path to skip search.
4951
pub path: Option<String>,
50-
52+
5153
/// Show git blame with syntax highlighting (files only)
5254
#[arg(short = 'b', long = "blame")]
5355
pub blame: bool,
54-
56+
5557
/// Show dates only
5658
/// Regular mode: "07 Jun 2025"
5759
/// Blame mode: "07 Jun | 1 | code content"
5860
#[arg(short = 'd', long = "date-only")]
5961
pub date_only: bool,
60-
62+
6163
/// Show commit messages on separate indented lines
6264
#[arg(short = 'm', long = "commit-message")]
6365
pub commit_message: bool,
64-
66+
6567
/// Show the last N unique contributors (regular mode only)
6668
///
6769
/// Lists the most recent N unique people who modified the path, with an
6870
/// indication if fewer contributors exist than requested.
6971
#[arg(short = 'l', long = "last", value_name = "N")]
7072
pub last: Option<usize>,
71-
73+
7274
/// Disable colored output and syntax highlighting
7375
#[arg(long = "no-color")]
7476
pub no_color: bool,
75-
}
77+
}

0 commit comments

Comments
 (0)