feat: convert help-table to dynamic width and update AGENTS.md formatting

- Converted help-table function in task.template to use dynamic column widths based on content
- Removed fixed width parameters and implemented logic to calculate maximum widths from table data
- Added new prompt file documenting the conversion from fixed to dynamic width table
- Removed redundant bold formatting in AGENTS.md for consistency with project style
- Updated task.template permissions to executable (755)
This commit is contained in:
Janik von Rotz committed 2026-02-17 10:28:24 +01:00
1 parent a3dde7ff83
commit 82619ece68
3 files changed
+58 -1

No files matched your search

+1 -1
View File
@@ -47,7 +47,7 @@ This project uses the <https://taskfile.build/> standard.
The `./task` file is a bash script that provides all functions necessary to work with this project.
**Execute**: Always try to run a command with the `./task` file script.
Always try to run a command with the `./task` file script.
## Coding conventions
@@ -0,0 +1,57 @@
Check if the `task` file has `help-table` function that has a fixed width.
```bash
help-table() {
local cmd_width=30
local opt_width=26
local desc_width=70
local column="| %-${cmd_width}s | %-${opt_width}s | %-${desc_width}s |\n"
printf "$column" 'Command' 'Option' 'Description'
echo "|$(printf '%*s' $((cmd_width + 2)) '' | tr ' ' '-')|$(printf '%*s' $((opt_width + 2)) '' | tr ' ' '-')|$(printf '%*s' $((desc_width + 2)) '' | tr ' ' '-')|"
# Env
printf "$column" 'version' '' 'Show tool versions.'
...
}
```
Convert the fixed with do a dynamic width.
```bash
help-table() {
local -a rows
local max_cmd=7 max_opt=6 max_desc=11
rows+=("Command|Option|Description")
# Env
rows+=("version||Show version of required tools.")
...
for row in "${rows[@]}"; do
IFS='|' read -r cmd opt desc <<< "$row"
(( ${#cmd} > max_cmd )) && max_cmd=${#cmd}
(( ${#opt} > max_opt )) && max_opt=${#opt}
(( ${#desc} > max_desc )) && max_desc=${#desc}
done
printf '| %-*s | %-*s | %-*s |\n' \
"$max_cmd" "Command" \
"$max_opt" "Option" \
"$max_desc" "Description"
printf '|-%*s-|-%*s-|-%*s-|\n' \
"$max_cmd" "$(printf '%*s' "$max_cmd" '' | tr ' ' '-')" \
"$max_opt" "$(printf '%*s' "$max_opt" '' | tr ' ' '-')" \
"$max_desc" "$(printf '%*s' "$max_desc" '' | tr ' ' '-')"
for row in "${rows[@]:1}"; do
IFS='|' read -r cmd opt desc <<< "$row"
printf '| %-*s | %-*s | %-*s |\n' \
"$max_cmd" "$cmd" \
"$max_opt" "$opt" \
"$max_desc" "$desc"
done
}
```
Only comment the row entry section. Do not comment the logic of the dynamic table code.
Regular → Executable
View File
File mode changed.