[PATCH shepherd] herd: Suggest alternatives when action and service are likely swapped.

OpenSubmitted by Leo Prikler.
Details
3 participants
  • Oleg Pykhalov
  • Jonathan Brielmaier
  • Leo Prikler
Owner
unassigned
Severity
normal
L
L
Leo Prikler wrote on 2 Dec 2020 10:21
(address . guix-patches@gnu.org)
20201202092106.22770-1-leo.prikler@student.tugraz.at
* modules/shepherd/script/herd.scm (run-command)[reply error]: Report a moredescriptive error if service could reasonably have been an action.--- modules/shepherd/scripts/herd.scm | 9 +++++++++ 1 file changed, 9 insertions(+)
Toggle diff (22 lines)diff --git a/modules/shepherd/scripts/herd.scm b/modules/shepherd/scripts/herd.scmindex 106de1e..a178f51 100644--- a/modules/shepherd/scripts/herd.scm+++ b/modules/shepherd/scripts/herd.scm@@ -179,6 +179,15 @@ the daemon via SOCKET-FILE." ('messages messages)) (for-each display-line messages) (report-command-error error)+ (match (list action service)+ ((_ (or 'start 'stop 'status 'doc))+ (report-error (l10n "did you mean 'herd ~a ~a'?")+ service action))+ ((root (or 'help 'halt 'power-off 'load 'eval 'unload 'reload+ 'daemonize 'persistency 'no-persistency 'cd 'restart))+ (report-error (l10n "did you mean 'herd ~a ~a'?")+ service action))+ ((_ _) *unspecified*)) (exit 1)) ((? eof-object?) ;; When stopping shepherd, we may get an EOF in lieu of a real reply,-- 2.29.2
J
J
Jonathan Brielmaier wrote on 2 Dec 2020 21:03
(address . guix-patches@gnu.org)
c7c5ce55-a080-91c6-d29c-bbc0aa181492@web.de
On 02.12.20 10:21, Leo Prikler wrote:
Toggle quote (3 lines)> * modules/shepherd/script/herd.scm (run-command)[reply error]: Report a more> descriptive error if service could reasonably have been an action.
I didn't test it, but it sounds like a good idea :)
It reminds me that I should maybe write bash completions files forshepherd as it annoys me pretty hard ^^
O
O
Oleg Pykhalov wrote on 4 Dec 2020 18:18
(name . Jonathan Brielmaier)(address . jonathan.brielmaier@web.de)(address . 45004@debbugs.gnu.org)
87a6utqyku.fsf@gmail.com
Jonathan Brielmaier <jonathan.brielmaier@web.de> writes:
[…]
Toggle quote (3 lines)> It reminds me that I should maybe write bash completions files for> shepherd as it annoys me pretty hard ^^
You could take my, which probably should be improved before merging toShepherd IMHO, e.g. avoid 'awk'.
~/.local/share/bash-completion/completions/herd
_herd_complete_service(){ local command="${COMP_WORDS[1]}" local services="$(sudo herd status | awk '/*/ || /^ +/ || /^ -/ { print $NF }' | sort -u)" COMPREPLY=($(compgen -W "$services" -- "${COMP_WORDS[$COMP_CWORD]}"))}
_herd_is_command (){ local word local result="false" for word in ${COMP_WORDS[*]}t do if [ "$word" = "$1" ] then result=true break fi done $result}
_herd_complete(){ local word_count=${#COMP_WORDS[*]} local word_at_point="${COMP_WORDS[$COMP_CWORD]}" case $COMP_CWORD in 1) if [ -z "$_herd_subcommands" ] then # Cache the list of subcommands to speed things up. _herd_subcommands="enable disable start status stop" fi COMPREPLY=($(compgen -W "$_herd_subcommands" -- "${COMP_WORDS[$COMP_CWORD]}")) ;; *) case $COMP_CWORD in 2) _herd_complete_service;; esac ;; esac}
complete -F _herd_complete herd
-----BEGIN PGP SIGNATURE-----
iQJIBAEBCgAyFiEEcjhxI46s62NFSFhXFn+OpQAa+pwFAl/Kb3IUHGdvLndpZ3VzdEBnbWFpbC5jb20ACgkQFn+OpQAa+pyufhAAhJce5fa8tK3aO/dzrXaD7pu4B6Ig59gSYTIjPOojLT2r7WqOeBLwIw1opQrRdKF9p5b5vxrnaAcB8amJobzNKTyVSP3fuHvAelAU/bv3BUHobOpZA+VxQJkK928pQRi2IKsvCh87GZ31PdevxOTWCkb74VRPp4azpvdz7vsO4sAq6KJPGo+Mfpo2U4BWxFgif9yPP3Gv9dVEYcHCL/3i1rtuUdvBPK/iFUvKoxzZLd/hMRtUvfPiyc+l57Mlhb8P0gIiWF7/dmLtVx+X85hTrMx8r71ZVRODRxEz5aOM3uQbWYyV4PzqTWfJueWuxj81AYhPFHAeQSyrbeDng+wM1cg1nDI5JTMkEBr4kdOLw58EdSa+JE6M2erLHG4WTnbbIaAXAKdVKOdgSwq0hP1CEqsnKfVsqaP2OO9+UciB4DaqPr+dS1B1gbUGMW0q4dLylQoYuNAi7YWbHFBCPCDCK0YUfH1EQYBnk7wDdNaGus3LBj4/1geqjUHzfziUjvt7FLlPd9kPLlfEuJgAoPM+nVm+DkJSXlDT3L9VpmOBLQTZWYemXTqi6wpf6HJKl3vR/vDU/BrokpZjgpPBcnbGlnQ/UlwMziUC36KNh6lG6D6IPDtwzg/zTv/HKAnyHc+feYjaZFGijMDUYPDJ6UUGoFgJV/iiUWmoxzacE2YrUcU==MTyf-----END PGP SIGNATURE-----
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send email to 45004@debbugs.gnu.org