Skip to content

Commit 28af9a0

Browse files
committed
fmt precommit
1 parent 2bb8f03 commit 28af9a0

File tree

2 files changed

+26
-23
lines changed

2 files changed

+26
-23
lines changed

justfile

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
set windows-shell := ["pwsh", "-NoLogo", "-NoProfileLoadTime", "-Command"]
2-
31
project_name := "http-server"
42
profile := env_var_or_default("profile", "debug")
53

@@ -54,7 +52,6 @@ else \
5452
out_dir := join(justfile_directory(), "target", os + "-" + arch, profile)
5553
out_dir_link := join(justfile_directory(), "target", profile)
5654

57-
[unix]
5855
build:
5956
@rm -rf "{{out_dir}}"
6057
@rm -rf "{{out_dir_link}}"
@@ -63,15 +60,6 @@ build:
6360
@cp "./target/.cargo/{{target}}/{{profile}}/{{project_name}}" "{{out_dir}}"
6461
@# ln -rs "{{out_dir}}" "{{out_dir_link}}"
6562

66-
[windows]
67-
build:
68-
@if (Test-Path {{out_dir}}) { Remove-Item -Recurse -Force {{out_dir}} | Out-Null }
69-
@if (Test-Path {{out_dir_link}}) { Remove-Item -Recurse -Force {{out_dir_link}} | Out-Null }
70-
@New-Item -ItemType "directory" -Force -Path "{{out_dir}}" | Out-Null
71-
cargo build {{profile_cargo}} {{target_cargo}}
72-
Copy-Item ".\target\.cargo\{{target}}\{{profile}}\{{project_name}}.exe" -Destination "{{out_dir}}" | Out-Null
73-
@# New-Item -Path "{{out_dir}}" -ItemType SymbolicLink -Value "{{out_dir_link}}"
74-
7563
[unix]
7664
run *ARGS:
7765
just build
@@ -85,17 +73,32 @@ run *ARGS:
8573
test:
8674
cargo test
8775

88-
lint:
89-
cargo +nightly clippy -- --deny "warnings"
90-
91-
lint_fix *ARGS:
92-
cargo +nightly clippy --fix --allow-staged -- --deny "warnings"
93-
94-
fmt:
95-
cargo +nightly fmt --check
96-
97-
fmt_fix *ARGS:
98-
cargo +nightly fmt
76+
format arg="--check":
77+
#!/usr/bin/env bash
78+
just fmt {{arg}}
79+
just lint {{arg}}
80+
81+
fmt arg="--check":
82+
#!/usr/bin/env bash
83+
args=""
84+
while read -r line; do
85+
line=$(echo "$line" | tr -d "[:space:]")
86+
args="$args --config $line"
87+
done < "rust-fmt.toml"
88+
args=$(echo "$args" | xargs)
89+
if [ "{{arg}}" = "--fix" ]; then
90+
cargo fmt -- $args
91+
else
92+
cargo fmt --check -- $args
93+
fi
94+
95+
lint arg="--check":
96+
#!/usr/bin/env bash
97+
if [ "{{arg}}" = "--fix" ]; then
98+
cargo clippy --fix --allow-dirty -- --deny "warnings"
99+
else
100+
cargo clippy -- --deny "warnings"
101+
fi
99102

100103
watch *ARGS:
101104
cargo watch --watch src -- just run {{ARGS}}
File renamed without changes.

0 commit comments

Comments
 (0)