Skip to content

Commit

Permalink
add service completion
Browse files Browse the repository at this point in the history
  • Loading branch information
nyxnor committed Aug 23, 2022
1 parent 81f6fab commit c6cfbc1
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 24 deletions.
7 changes: 7 additions & 0 deletions usr/share/bash-completion/.shellcheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,10 @@ disable=SC2207 # suggested alternatives fail in posix mode or use temp files
#disable=SC2016
#disable=SC2086
#disable=SC2155


## This is onionjuggler rc
source=/dev/null
## disabling 2154 is raw but the variables
## are sourced from a non constant source
disable=SC2154
37 changes: 31 additions & 6 deletions usr/share/bash-completion/completions/onionjuggler-cli
Original file line number Diff line number Diff line change
@@ -1,15 +1,40 @@
# onionjuggler-cli(8) completion -*- shell-script -*-

#COMPREPLY=($(_comp_xfunc onionjuggler-cli services $cur))
_comp_xfunc_onionjuggler_cli_services()
{
. /usr/share/onionjuggler/defaults.sh || return
source_conf || return
test -f "${tor_conf}" || return

# shellcheck disable=SC2013
for hs in $(grep "HiddenServiceDir ${tor_data_dir_services}/" "${tor_conf}" \
| sed "s|HiddenServiceDir ||")
do
service_clean="${hs%*/}"
service_base="${service_clean##*/}"
service_path="${service_clean%/*}"
if test -z "${service_store}"; then
service_store="$(printf '%s\n' "${service_base}")"
else
service_store="$(printf '%s\n%s\n' "${service_store}" "${service_base}")"
fi
done

printf '%s\n' "${service_store}"
}

_onionjuggler_cli()
{
local cur prev words cword
_init_completion -s || return

case $prev in
--gateway | --purge | --quiet | --renew )
--port | --gateway | --purge | --renew | --quiet )
return
;;
--service | --port )
--service )
COMPREPLY=($(compgen -W "$(_comp_xfunc_onionjuggler_cli_services)" -- "$cur"))
return
;;
--hs-version )
Expand All @@ -20,14 +45,14 @@ _onionjuggler_cli()
COMPREPLY=($(compgen -W "tcp unix" -- "$cur"))
return
;;
--on | --off | --list | --getopt )
--signal )
COMPREPLY=($(compgen -W "reload restart none" -- "$cur"))
return
;;
--help | --version | --getconf )
--on | --off | --list | --getopt )
return
;;
--signal )
COMPREPLY=($(compgen -W "reload restart none" -- "$cur"))
--help | --version | --getconf )
return
;;
esac
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,24 @@ _onionjuggler_cli_auth_client()
_init_completion -s || return

case $prev in
--client | --service | --replace-file | \
--client-priv-config | --client-priv-key | \
--on | --off | --list | --getopt )
--client | --replace-file | \
--client-priv-config | --client-priv-key )
return
;;
--client-priv-file )
_filedir auth_private
return
;;
--help | --version | --getconf )
return
;;
--signal )
COMPREPLY=($(compgen -W "reload restart none" -- "$cur"))
return
;;
--on | --off | --list | --getopt )
return
;;
--help | --version | --getconf )
return
;;
esac

if [[ $cur == -* ]]; then
Expand Down
18 changes: 12 additions & 6 deletions usr/share/bash-completion/completions/onionjuggler-cli-auth-server
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,28 @@ _onionjuggler_cli_auth_server()
_init_completion -s || return

case $prev in
--client | --service | --replace-file | \
--client-pub-config | --client-pub-key | \
--on | --off | --list | --getopt )
--client | --replace-file | \
--client-pub-config | --client-pub-key )
return
;;
--client-pub-file )
_filedir auth
--service )
COMPREPLY=($(compgen -W "$(_comp_xfunc onionjuggler-cli services)" -- "$cur"))
return
;;
--help | --version | --getconf )
--client-pub-file )
_filedir auth
return
;;
--signal )
COMPREPLY=($(compgen -W "reload restart none" -- "$cur"))
return
;;
--on | --off | --list | --getopt )
return
;;
--help | --version | --getconf )
return
;;
esac

if [[ $cur == -* ]]; then
Expand Down
12 changes: 6 additions & 6 deletions usr/share/bash-completion/completions/onionjuggler-cli-web
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ _onionjuggler_cli_web()
_init_completion -s || return

case $prev in
-no-check-service | \
--on | --off | --list | --getopt )
return
;;
--port )
--port | -no-check-service )
return
;;
--service )
COMPREPLY=($(compgen -W "$(_comp_xfunc onionjuggler-cli services)" -- "$cur"))
return
;;
--folder )
_filedir
_filedir -d
return
;;
--on | --off | --list | --getopt )
return
;;
--help | --version | --getconf )
Expand Down

0 comments on commit c6cfbc1

Please sign in to comment.