Skip to content

Commit

Permalink
mandb: include short name in the longname description
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Sep 16, 2022
1 parent 7d238c0 commit 60b6989
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/ChangeLog.md
Expand Up @@ -223,6 +223,7 @@
- mandb: fix a bug that the description is inserted for `--no-OPTION` `#D1761` 88614b8
- mandb: fix a bug that the man page is not correctly searched (fixup 2365e09) `#D1794` 65ffe70
- mandb: support the man-page formats of `man ls` in coreutils/Japanese and in macOS `#D1847` fa32829
- mandb: include short name in the longname description `#D1879` xxxxxxx
- edit: work around the wrong job information of Bash in trap handlers (reported by 3ximus) `#D1435` `#D1436` bc4735e
- edit (command-help): work around the Bash bug that tempenv vanishes with `builtin eval` `#D1438` 8379d4a
- global: suppress missing locale errors (reported by 3ximus) `#D1440` 4d3c595
Expand Down
34 changes: 28 additions & 6 deletions lib/core-complete.sh
Expand Up @@ -4391,13 +4391,24 @@ function ble/complete/mandb/.generate-cache-from-man {
END { flush_topic(); }
' | ble/complete/mandb/convert-mandoc 2>/dev/null | ble/bin/awk -F "$_ble_term_FS" '
function flush_pair(_, i) {
function flush_pair(_, i, desc, prev_opt) {
if (g_option_count) {
gsub(/\034/, "\x1b[7m^\\\x1b[27m", g_desc);
sub(/(\. |; ).*/, ".", g_desc); # Long descriptions are truncated.
for (i = 0; i < g_option_count; i++)
print g_options[i] FS g_desc;
for (i = 0; i < g_option_count; i++) {
desc = g_desc;
# show a short option
if (i > 0 && g_options[i] ~ /^--/) {
prev_opt = g_options[i - 1];
sub(/\034.*/, "", prev_opt);
if (prev_opt ~ /^-[^-]$/)
desc = "\033[1m[\033[0;36m" prev_opt "\033[0;1m]\033[m " desc;
}
print g_options[i] FS desc;
}
}
g_option_count = 0;
g_desc = "";
Expand Down Expand Up @@ -4676,10 +4687,21 @@ function ble/complete/mandb:help/generate-cache {
}
return ret;
}
function flush_data(_, i) {
function flush_data(_, i, desc, prev_opt) {
if (g_indent < 0) return;
for (i = 0; i < g_keys_count; i++)
entries_register(g_keys[i] FS g_desc, g_indent);
for (i = 0; i < g_keys_count; i++) {
desc = g_desc;
# show a short option
if (i > 0 && g_keys[i] ~ /^--/) {
prev_opt = g_keys[i - 1];
sub(/\034.*/, "", prev_opt);
if (prev_opt ~ /^-[^-]$/)
desc = "\033[1m[\033[0;36m" prev_opt "\033[0;1m]\033[m " desc;
}
entries_register(g_keys[i] FS desc, g_indent);
}
g_indent = -1;
g_keys_count = 0;
g_desc = "";
Expand Down
7 changes: 7 additions & 0 deletions note.txt
Expand Up @@ -6599,6 +6599,13 @@ bash_tips

2022-09-16

* mandb: longname の説明に対応する short option 名を併記するう (suggested by bbyfacekiller) [#D1879]
https://github.com/akinomyoga/ble.sh/issues/231

これはもしかすると実際に short flag も選択できる様にして欲しいという要求か
もしれないとも思ったがよく分からないので、取り敢えず作ってみて見た目だけ見
せたらそれで良いというのでそのまま採用する事にする。

* color: term_index_colors を優先する様に変更 (motivated by StavromulaBeta) [#D1878]

これで強制的に減色したい時にユーザーが term_index_colors を設定できる。
Expand Down

0 comments on commit 60b6989

Please sign in to comment.