Add modernize tasks to Taskfile
This commit is contained in:
10
Taskfile.yml
10
Taskfile.yml
@ -79,6 +79,16 @@ tasks:
|
||||
cmds:
|
||||
- golangci-lint run --fix
|
||||
|
||||
modernize:
|
||||
desc: Apply gopls modernize fixes
|
||||
cmds:
|
||||
- go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix ./...
|
||||
|
||||
modernize:test:
|
||||
desc: Apply gopls modernize fixes including tests
|
||||
cmds:
|
||||
- go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix -test ./...
|
||||
|
||||
clean:
|
||||
desc: Remove built binary
|
||||
cmds:
|
||||
|
||||
@ -1,75 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
STATUSLINE_WIDTH_OFFSET=7
|
||||
|
||||
input=$(cat)
|
||||
|
||||
# Extract values using jq
|
||||
model=$(echo "${input}" | jq -r '.model.display_name')
|
||||
cwd=$(echo "${input}" | jq -r '.workspace.current_dir')
|
||||
|
||||
# Context window usage
|
||||
context_size=$(echo "${input}" | jq -r '.context_window.context_window_size')
|
||||
usage=$(echo "${input}" | jq '.context_window.current_usage')
|
||||
|
||||
if [[ "${usage}" != "null" ]]; then
|
||||
current_tokens=$(echo "${usage}" | jq '.input_tokens + .cache_creation_input_tokens + .cache_read_input_tokens')
|
||||
current_k=$((current_tokens / 1000))
|
||||
total_k=$((context_size / 1000))
|
||||
context_info="${current_k}k/${total_k}k"
|
||||
else
|
||||
total_k=$((context_size / 1000))
|
||||
context_info="0/${total_k}k"
|
||||
fi
|
||||
|
||||
dir_name=$(basename "${cwd}")
|
||||
|
||||
cd "${cwd}" 2>/dev/null || cd /
|
||||
|
||||
if pgrep -x gitea >/dev/null 2>&1; then
|
||||
gitea_status=$'\033[32m●\033[0m'
|
||||
else
|
||||
gitea_status=$'\033[31m●\033[0m'
|
||||
fi
|
||||
|
||||
git_info=""
|
||||
|
||||
if git rev-parse --git-dir >/dev/null 2>&1; then
|
||||
branch=$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD 2>/dev/null)
|
||||
if [[ -n "${branch}" ]]; then
|
||||
if git diff --no-ext-diff --quiet --exit-code --no-optional-locks 2>/dev/null &&
|
||||
git diff-index --cached --quiet HEAD --no-optional-locks 2>/dev/null; then
|
||||
git_info=" git:(${branch})"
|
||||
else
|
||||
git_info=" git:(${branch}) ✗"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Build left and right parts
|
||||
left=$(printf '%s \033[35m%s\033[0m \033[1;32m➜\033[0m \033[36m%s\033[0m%s' \
|
||||
"${gitea_status}" "${model}" "${dir_name}" "${git_info}")
|
||||
right=$(printf '\033[33m%s\033[0m' "${context_info}")
|
||||
|
||||
# Strip ANSI codes to get visible lengths
|
||||
strip_ansi() {
|
||||
echo -e "$1" | sed $'s/\033\\[[0-9;]*m//g'
|
||||
}
|
||||
|
||||
left_visible=$(strip_ansi "${left}")
|
||||
right_visible=$(strip_ansi "${right}")
|
||||
|
||||
left_len=${#left_visible}
|
||||
right_len=${#right_visible}
|
||||
|
||||
# Get terminal width (subtract offset for Claude Code statusline area)
|
||||
term_width=$(( $(tput cols 2>/dev/null || echo 80) - STATUSLINE_WIDTH_OFFSET ))
|
||||
|
||||
# Calculate padding
|
||||
padding=$((term_width - left_len - right_len))
|
||||
if [[ ${padding} -lt 1 ]]; then
|
||||
padding=1
|
||||
fi
|
||||
|
||||
# Output with padding
|
||||
printf '%s%*s%s' "${left}" "${padding}" "" "${right}"
|
||||
Reference in New Issue
Block a user