GNU bug report logs - #45004
[PATCH shepherd] herd: Suggest alternatives when action and service are likely swapped.

Previous Next

Package: guix-patches;

Reported by: Leo Prikler <leo.prikler <at> student.tugraz.at>

Date: Wed, 2 Dec 2020 09:23:01 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #14 received at 45004 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Oleg Pykhalov <go.wigust <at> gmail.com>
Cc: 45004 <at> debbugs.gnu.org, Jonathan Brielmaier <jonathan.brielmaier <at> web.de>
Subject: Bash completion for ‘herd’
Date: Fri, 02 Jun 2023 15:56:11 +0200
Hi Oleg,

Oleg Pykhalov <go.wigust <at> gmail.com> skribis:

> You could take my, which probably should be improved before merging to
> Shepherd 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

Would you mind polishing a bit (as you see fit; perhaps use grep/sed
rather than Awk?) and submitting a patch for this?  I’d be happy to
apply it!

Thanks,
Ludo’.




This bug report was last modified 2 years and 42 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.