Skip to content

refactor: more API/naming work #1025

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Aug 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions completions/_modules
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,18 @@ _comp_cmd_module()
elif ((cword == 2)); then
case $prev in
add | display | help | load | show | whatis)
# TODO:API: use generator call?
_comp_cmd_module__compgen_avail
;;
rm | switch | swap | unload | update)
# TODO:API: use generator call?
_comp_cmd_module__compgen_list
;;
unuse)
# TODO:API: use generator call?
_comp_cmd_module__compgen_path
;;
esac
elif ((cword == 3)); then
case ${words[1]} in
swap | switch)
# TODO:API: use generator call?
_comp_cmd_module__compgen_avail
;;
esac
Expand Down
10 changes: 5 additions & 5 deletions completions/apt-cache
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
# Debian apt-cache(8) completion -*- shell-script -*-

# List APT binary packages
# TODO:API: rework to use vars rather than outputting
# TODO:API: make it a generator
# @since 2.12
_comp_xfunc_apt_cache_packages()
{
_comp_cmd_apt_cache__packages apt-cache
}

# TODO:API: rework to use vars rather than outputting
# TODO:API: make it a generator
_comp_cmd_apt_cache__packages()
{
"$1" --no-generate pkgnames "$cur" 2>/dev/null || :
}

# List APT source packages
# TODO:API: rework to use vars rather than outputting
# TODO:API: make it a generator
# @since 2.12
_comp_xfunc_apt_cache_sources()
{
_comp_cmd_apt_cache__sources apt-cache "$1"
}

# TODO:API: rework to use vars rather than outputting
# TODO:API: make it a generator
_comp_cmd_apt_cache__sources()
{
local ret
Expand All @@ -32,7 +32,7 @@ _comp_cmd_apt_cache__sources()
}

# List APT source packages
# TODO:API: rework to use vars rather than outputting
# TODO:API: make it a generator
# @since 2.12
_comp_xfunc_apt_cache_src_packages()
{
Expand Down
1 change: 1 addition & 0 deletions completions/apt-get
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Debian apt-get(8) completion -*- shell-script -*-

# @since 2.12
# TODO:API: make it a generator
_comp_xfunc_apt_get_installed_packages()
{
if [[ -f /etc/debian_version ]]; then
Expand Down
2 changes: 1 addition & 1 deletion completions/arch
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ _comp_have_command mailmanctl &&
# Prefer `list_lists` in the same dir as command
local pathcmd
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
_comp_xfunc list_lists mailman_lists
_comp_compgen -x list_lists mailman_lists
;;
2)
_comp_compgen_filedir
Expand Down
1 change: 1 addition & 0 deletions completions/asciidoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# asciidoc(1) completion -*- shell-script -*-

# @since 2.12
# TODO:API: make it a default, replace by default
_comp_xfunc_asciidoc_doctype()
{
_comp_compgen -a -- -W 'article book manpage'
Expand Down
20 changes: 8 additions & 12 deletions completions/bts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# bts completion -*- shell-script -*-

# Generate bug numbers from bugs cache in ~/.devscripts_cache/bts
# TODO:API: generator
_comp_cmd_bts__cached_bugs()
_comp_cmd_bts__compgen_cached_bugs()
{
[[ -d $HOME/.devscripts_cache/bts ]] || return 1
local bugs=$(
Expand All @@ -14,8 +13,7 @@ _comp_cmd_bts__cached_bugs()
}

# Generate APT source packages prefixed with "src:"
# TODO:API: generator
_comp_cmd_bts__src_packages_with_prefix()
_comp_cmd_bts__compgen_src_packages_with_prefix()
{
local ppn=${cur:4} # partial package name, after stripping "src:"
_comp_compgen -ac "$ppn" split -P "src:" -- \
Expand All @@ -30,8 +28,8 @@ _comp_cmd_bts()
case $prev in
show | bugs)
_comp_compgen -- -W 'release-critical RC from: tag: usertag:'
_comp_cmd_bts__cached_bugs
_comp_cmd_bts__src_packages_with_prefix
_comp_cmd_bts__compgen_cached_bugs
_comp_cmd_bts__compgen_src_packages_with_prefix
return
;;
select)
Expand All @@ -42,7 +40,7 @@ _comp_cmd_bts()
;;
status)
_comp_compgen -- -W 'file: fields: verbose'
_comp_cmd_bts__cached_bugs
_comp_cmd_bts__compgen_cached_bugs
return
;;
block | unblock)
Expand All @@ -60,8 +58,7 @@ _comp_cmd_bts()
return
;;
clone | "done" | reopen | archive | unarchive | retitle | summary | submitter | found | notfound | fixed | notfixed | merge | forcemerge | unmerge | claim | unclaim | forwarded | notforwarded | owner | noowner | subscribe | unsubscribe | reportspam | spamreport | affects | usertag | usertags | reassign | tag | tags)
COMPREPLY=()
_comp_cmd_bts__cached_bugs
_comp_cmd_bts__compgen_cached_bugs
return
;;
package)
Expand All @@ -70,19 +67,18 @@ _comp_cmd_bts()
;;
cache)
COMPREPLY=($(_comp_xfunc apt-cache packages))
_comp_cmd_bts__src_packages_with_prefix
_comp_cmd_bts__compgen_src_packages_with_prefix
_comp_compgen -a -- -W 'from: release-critical RC'
return
;;
cleancache)
COMPREPLY=($(_comp_xfunc apt-cache packages))
_comp_cmd_bts__src_packages_with_prefix
_comp_cmd_bts__compgen_src_packages_with_prefix
_comp_compgen -a -- -W 'from: tag: usertag: ALL'
return
;;
user)
# non-predicible arguments
COMPREPLY=()
return
;;
:)
Expand Down
2 changes: 1 addition & 1 deletion completions/change_pw
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ _comp_cmd_change_pw()
# Prefer `list_lists` in the same dir as command
local pathcmd
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
_comp_xfunc list_lists mailman_lists
_comp_compgen -x list_lists mailman_lists
return
;;
esac
Expand Down
2 changes: 1 addition & 1 deletion completions/check_db
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ _comp_cmd_check_db()
# Prefer `list_lists` in the same dir as command
local pathcmd
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
_comp_xfunc list_lists mailman_lists
_comp_compgen -x list_lists mailman_lists
fi

} &&
Expand Down
2 changes: 1 addition & 1 deletion completions/clone_member
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ _comp_cmd_clone_member()
# Prefer `list_lists` in the same dir as command
local pathcmd
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
_comp_xfunc list_lists mailman_lists
_comp_compgen -x list_lists mailman_lists
return
;;
esac
Expand Down
2 changes: 1 addition & 1 deletion completions/curl
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ _comp_cmd_curl()
return
;;
--pubkey)
_comp_xfunc ssh identityfile pub
_comp_compgen -x ssh identityfile pub
return
;;
--request | -${noargopts}X)
Expand Down
Loading