unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Oleg Pykhalov <go.wigust@gmail.com>
To: Jonathan Brielmaier <jonathan.brielmaier@web.de>
Cc: 45004@debbugs.gnu.org
Subject: [bug#45004] [PATCH shepherd] herd: Suggest alternatives when action and service are likely swapped.
Date: Fri, 04 Dec 2020 20:18:41 +0300	[thread overview]
Message-ID: <87a6utqyku.fsf@gmail.com> (raw)
In-Reply-To: <c7c5ce55-a080-91c6-d29c-bbc0aa181492@web.de> (Jonathan Brielmaier's message of "Wed, 2 Dec 2020 21:03:54 +0100")


[-- Attachment #1.1: Type: text/plain, Size: 343 bytes --]

Jonathan Brielmaier <jonathan.brielmaier@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


[-- Attachment #1.2: herd completion --]
[-- Type: text/plain, Size: 980 bytes --]

_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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]

  reply	other threads:[~2020-12-04 20:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-02  9:21 [bug#45004] [PATCH shepherd] herd: Suggest alternatives when action and service are likely swapped Leo Prikler
2020-12-02 20:03 ` Jonathan Brielmaier
2020-12-04 17:18   ` Oleg Pykhalov [this message]
2023-06-02 13:56     ` [bug#45004] Bash completion for ‘herd’ Ludovic Courtès
2023-06-02 22:23       ` Oleg Pykhalov
2023-06-02 14:04 ` bug#45004: [PATCH shepherd] herd: Suggest alternatives when action and service are likely swapped Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a6utqyku.fsf@gmail.com \
    --to=go.wigust@gmail.com \
    --cc=45004@debbugs.gnu.org \
    --cc=jonathan.brielmaier@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).