-
Notifications
You must be signed in to change notification settings - Fork 1
/
justfile
149 lines (112 loc) · 3.66 KB
/
justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
set shell := ["zsh", "-euyc"]
# F
set dotenv-load := true
# Doesn't work??, Get this to be a just variable
CI := if env_var_or_default("CI", "1") == "0" { "--color=never" } else { "--color=always" }
# version := `rg --color=never --pcre2 -oIN '^version = "\K(\d+\.?)+' Cargo.toml`
# Doesn't not export and read
rl := if env_var_or_default("rl", "0") == "1" { "RUST_LOG=debug" } else { "" }
# export RUST_LOG := "debug"
debug:
echo $TASKRC $TASKDATA
bt := '0'
export RUST_BACKTRACE := bt
log := "warn"
export JUST_LOG := log
defaut:
@just --choose
alias e := edit
edit:
@$EDITOR {{justfile()}}
# Can use noglob or sh -c
# sh -c 'RUST_LOG=debug cargo run {{CI}} -- {{ARGS}}'
alias r := run
run *ARGS:
{{rl}} noglob cargo run {{CI}} -- {{ARGS}}
fmt:
cargo fmt -- --check --files-with-diff {{CI}}
fmt-all:
cargo fmt --all -- --check --files-with-diff {{CI}}
audit:
cargo audit --deny warnings {{CI}}
check:
cargo check --all-features {{CI}}
clippy:
cargo clippy --all --all-targets --all-features {{CI}}
# cargo clippy --all-features {{CI}} -- --deny warnings --deny clippy::all
alias br := build-release
build-release:
cargo build --release --all-features {{CI}}
test *ARGS:
cargo test {{CI}} -- {{ARGS}}
###################################################################################
###################################################################################
man:
help2man \
--name 'tag files colorfully' \
--manual 'Wutag Manual' \
--no-info \
target/debug/wutag \
> man/wutag.1
sed -i "s,\x1B\[[0-9;]*[a-zA-Z],,g" man/wutag.1
view-man: man
man man/wutag.1
# sd '{{FROM}}' '{{TO}}' src/*.rs Cargo.toml
# replace FROM TO *GO:
# ruplacer '{{FROM}}' '{{TO}}' {{GO}} src/*.rs
#
# update-version NEW *GO:
# just replace {{version}} {{NEW}} {{GO}}
# just man
replace FROM TO:
-fd -tf -e rs -e toml | sad '{{FROM}}' '{{TO}}'
#
# @update-version NEW:
# -just replace {{version}} {{NEW}}
#
# @get-version:
# echo "{{version}}"
@lint:
print -Pr "%F{2}%BChecking for FIXME/TODO...%b%f"
rg -s '\bFIXME\b|\bFIX\b|\bDISCOVER\b|\bNOTE\b|\bNOTES\b|\bINFO\b|\bOPTIMIZE\b|\bXXX\b|\bEXPLAIN\b|\bTODO\b|\bHACK\b|\bBUG\b|\bBUGS\b' src/*.rs
print -Pr $'\n'"%F{2}%BChecking for long lines...%b%f"
rg --color=always '.{100}' src/*.rs
@code:
tokei -ft rust -s lines
@code-overall:
tokei -t rust
###################################################################################
###################################################################################
no-changes:
git diff --no-ext-diff --quiet --exit-code
d-merged:
git branch --merged | egrep -v "(^\*|master|dev) | xargs git branch -d"
###################################################################################
###################################################################################
preview-readme:
grip -b README.md
alias er := edit-readme
edit-readme:
@$EDITOR ${$(cargo locate-project | jq -r '.root'):h}/README.md
edit-main:
@$EDITOR ${$(cargo locate-project | jq -r '.root'):h}/src/main.rs
alias ee := edit-rust
edit-rust:
#!/usr/bin/env zsh
local -a files sel
files=$(command fd -Hi -tf -d2 -e rs)
sel=("$(
print -rl -- "$files[@]" | \
fzf --query="$1" \
--multi \
--select-1 \
--exit-0 \
--bind=ctrl-x:toggle-sort \
--preview-window=':nohidden,right:65%:wrap' \
--preview='([[ -f {} ]] && (bat --style=numbers --color=always {})) || \
([[ -d {} ]] && (exa -TL 3 --color=always --icons {} | less)) || \
echo {} 2> /dev/null | head -200'
)"
) || return
[[ -n "$sel" ]] && ${EDITOR:-vim} "${sel[@]}"
# vim: ft=just:et:sw=0:ts=2:sts=2:fdm=marker:fmr={{{,}}}: