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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 45004 in the body.
You can then email your comments to 45004 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#45004; Package guix-patches. (Wed, 02 Dec 2020 09:23:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Leo Prikler <leo.prikler <at> student.tugraz.at>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Wed, 02 Dec 2020 09:23:01 GMT) Full text and rfc822 format available.

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

From: Leo Prikler <leo.prikler <at> student.tugraz.at>
To: guix-patches <at> gnu.org
Subject: [PATCH shepherd] herd: Suggest alternatives when action and service
 are likely swapped.
Date: Wed,  2 Dec 2020 10:21:07 +0100
* modules/shepherd/script/herd.scm (run-command)[reply error]: Report a more
descriptive error if service could reasonably have been an action.
---
 modules/shepherd/scripts/herd.scm | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/modules/shepherd/scripts/herd.scm b/modules/shepherd/scripts/herd.scm
index 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





Information forwarded to guix-patches <at> gnu.org:
bug#45004; Package guix-patches. (Wed, 02 Dec 2020 20:05:02 GMT) Full text and rfc822 format available.

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

From: Jonathan Brielmaier <jonathan.brielmaier <at> web.de>
To: guix-patches <at> gnu.org
Subject: Re: [bug#45004] [PATCH shepherd] herd: Suggest alternatives when
 action and service are likely swapped.
Date: Wed, 2 Dec 2020 21:03:54 +0100
On 02.12.20 10:21, Leo Prikler wrote:
> * 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 for
shepherd as it annoys me pretty hard ^^




Information forwarded to guix-patches <at> gnu.org:
bug#45004; Package guix-patches. (Fri, 04 Dec 2020 17:19:01 GMT) Full text and rfc822 format available.

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

From: Oleg Pykhalov <go.wigust <at> gmail.com>
To: Jonathan Brielmaier <jonathan.brielmaier <at> web.de>
Cc: 45004 <at> debbugs.gnu.org
Subject: Re: [bug#45004] [PATCH shepherd] herd: Suggest alternatives when
 action and service are likely swapped.
Date: Fri, 04 Dec 2020 20:18:41 +0300
[Message part 1 (text/plain, inline)]
Jonathan Brielmaier <jonathan.brielmaier <at> web.de> writes:

[…]

> 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 to
Shepherd IMHO, e.g. avoid 'awk'.

~/.local/share/bash-completion/completions/herd

[herd (text/plain, attachment)]
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#45004; Package guix-patches. (Fri, 02 Jun 2023 13:57:02 GMT) Full text and rfc822 format available.

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’.




Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Fri, 02 Jun 2023 14:05:01 GMT) Full text and rfc822 format available.

Notification sent to Leo Prikler <leo.prikler <at> student.tugraz.at>:
bug acknowledged by developer. (Fri, 02 Jun 2023 14:05:02 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: Liliana Marie Prikler <liliana.prikler <at> gmail.com>
Cc: 45004-done <at> debbugs.gnu.org
Subject: Re: bug#45004: [PATCH shepherd] herd: Suggest alternatives when
 action and service are likely swapped.
Date: Fri, 02 Jun 2023 16:04:46 +0200
Hey Liliana,

> * modules/shepherd/script/herd.scm (run-command)[reply error]: Report a more
> descriptive error if service could reasonably have been an action.

I found this old patch of yours, which I find very useful.  So… finally
applied as Shepherd commit b9b15db9e5bda27287706b6727c462df686e7621!

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#45004; Package guix-patches. (Fri, 02 Jun 2023 22:24:02 GMT) Full text and rfc822 format available.

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

From: Oleg Pykhalov <go.wigust <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 45004 <at> debbugs.gnu.org, Jonathan Brielmaier <jonathan.brielmaier <at> web.de>
Subject: Re: Bash completion for ‘herd’
Date: Sat, 03 Jun 2023 01:23:24 +0300
[Message part 1 (text/plain, inline)]
Hi Ludovic,

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

[…]

> 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!

Done. Please check the 63860 issue.

Regards,
Oleg.
[signature.asc (application/pgp-signature, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 01 Jul 2023 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 291 days ago.

Previous Next


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