1- set windows-shell := [" pwsh" , " -NoLogo" , " -NoProfileLoadTime" , " -Command" ]
2-
31project_name := " http-server"
42profile := env_var_or_default (" profile" , " debug" )
53
5452out_dir := join (justfile_directory (), " target" , os + " -" + arch , profile)
5553out_dir_link := join (justfile_directory (), " target" , profile)
5654
57- [unix ]
5855build :
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 " .\t arget\. 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 ]
7664run * ARGS :
7765 just build
@@ -85,17 +73,32 @@ run *ARGS:
8573test :
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
100103watch * ARGS :
101104 cargo watch --watch src -- just run {{ ARGS}}
0 commit comments