public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] shell-completion.eclass
@ 2023-07-11 12:36 freijon
  2023-07-14  9:44 ` [gentoo-dev] shell-completion.eclass freijon
  0 siblings, 1 reply; 2+ messages in thread
From: freijon @ 2023-07-11 12:36 UTC (permalink / raw
  To: gentoo-dev@lists.gentoo.org


[-- Attachment #1.1.1: Type: text/plain, Size: 709 bytes --]

On July 2nd we had a discussion on #gentoo-guru on IRC about adding shell-completion.eclass to ::gentoo. It's already well established on GURU and used in 23 ebuilds. It's basically bash-completion-r1, but also includes `zsh` and `fish` with standard install locations for the completion scripts.
For the raison d'être, see: https://bugs.gentoo.org/843875

Check out the eclass here: https://gitweb.gentoo.org/repo/proj/guru.git/tree/eclass/shell-completion.eclass

I hereby ask for a code review and to add this eclass to the ::gentoo repository.

I offer to continue maintaining the eclass and Florian Schmaus (Flow) offered to co-maintain the eclass.

Please let me know your thoughts about this.

[-- Attachment #1.1.2.1: Type: text/html, Size: 1563 bytes --]

[-- Attachment #1.2: publickey - freijon@pm.me - 0x259C4FF5.asc --]
[-- Type: application/pgp-keys, Size: 3068 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 855 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [gentoo-dev] Re: shell-completion.eclass
  2023-07-11 12:36 [gentoo-dev] shell-completion.eclass freijon
@ 2023-07-14  9:44 ` freijon
  0 siblings, 0 replies; 2+ messages in thread
From: freijon @ 2023-07-14  9:44 UTC (permalink / raw
  To: gentoo-dev@lists.gentoo.org


[-- Attachment #1.1.1: Type: text/plain, Size: 4120 bytes --]

For convenience I attach the proposed eclass for review:

From: Jonas Frei <freijon@pm.me>Date:   Fri Jul 14 11:13:14 2023 +0200
Subject: shell-completion.eclass

shell-completion.eclass: Add new eclass

Signed-off-by: Jonas Frei <freijon@pm.me>
diff --git a/eclass/shell-completion.eclass b/eclass/shell-completion.eclass
new file mode 100644
index 000000000000..b7b59802a5f7
--- /dev/null
+++ b/eclass/shell-completion.eclass
@@ -0,0 +1,114 @@
+# Copyright 2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: shell-completion.eclass
+# @SUPPORTED_EAPIS: 8
+# @PROVIDES: bash-completion-r1
+# @AUTHOR:
+# Alfred Wingate <parona@protonmail.com>
+# @MAINTAINER:
+# Jonas Frei <freijon@pm.me>
+# @BLURB: a few quick functions to install various shell completion files
+# @DESCRIPTION:
+# This eclass provides a standardised way to install shell completions
+# for popular shells.  It inherits the already widely adopted
+# 'bash-completion-r1', thus extending on its functionality.
+
+case ${EAPI} in
+ 8) ;;
+ *) die "${ECLASS}: EAPI ${EAPI:-0} not supported"
+esac
+
+if [[ ! ${_SHELL_COMPLETION_ECLASS} ]]; then
+_SHELL_COMPLETION_ECLASS=1
+
+# Extend bash-completion-r1
+inherit bash-completion-r1
+
+# @FUNCTION: _shell-completion_get_fishcompdir
+# @INTERNAL
+# @RETURN: unprefixed fish completions directory
+_shell-completion_get_fishcompdir() {
+ echo "/usr/share/fish/vendor_completions.d"
+}
+
+# @FUNCTION: _shell-completion_get_zshcompdir
+# @INTERNAL
+# @RETURN: unprefixed zsh completions directory
+_shell-completion_get_zshcompdir() {
+ echo "/usr/share/zsh/site-functions"
+}
+
+# @FUNCTION: get_fishcompdir
+# @RETURN: the fish completions directory (with EPREFIX)
+get_fishcompdir() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ echo "${EPREFIX}$(_shell-completion_get_fishcompdir)"
+}
+
+# @FUNCTION: get_zshcompdir
+# @RETURN: the zsh completions directory (with EPREFIX)
+get_zshcompdir() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ echo "${EPREFIX}$(_shell-completion_get_zshcompdir)"
+}
+
+# @FUNCTION: dofishcomp
+# @USAGE: <file...>
+# @DESCRIPTION:
+# Install fish completion files passed as args.
+dofishcomp() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ (
+ insopts -m 0644
+ insinto "$(_shell-completion_get_fishcompdir)"
+ doins "${@}"
+ )
+}
+
+# @FUNCTION: dozshcomp
+# @USAGE: <file...>
+# @DESCRIPTION:
+# Install zsh completion files passed as args.
+dozshcomp() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ (
+ insopts -m 0644
+ insinto "$(_shell-completion_get_zshcompdir)"
+ doins "${@}"
+ )
+}
+
+# @FUNCTION: newfishcomp
+# @USAGE: <file> <newname>
+# @DESCRIPTION:
+# Install fish file under a new name.
+newfishcomp() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ (
+ insopts -m 0644
+ insinto "$(_shell-completion_get_fishcompdir)"
+ newins "${@}"
+ )
+}
+
+# @FUNCTION: newzshcomp
+# @USAGE: <file> <newname>
+# @DESCRIPTION:
+# Install zsh file under a new name.
+newzshcomp() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ (
+ insopts -m 0644
+ insinto "$(_shell-completion_get_zshcompdir)"
+ newins "${@}"
+ )
+}
+
+fi


------- Original Message -------
On Tuesday, July 11th, 2023 at 12:36 PM, freijon@pm.me <freijon@pm.me> wrote:


> On July 2nd we had a discussion on #gentoo-guru on IRC about adding shell-completion.eclass to ::gentoo. It's already well established on GURU and used in 23 ebuilds. It's basically bash-completion-r1, but also includes `zsh` and `fish` with standard install locations for the completion scripts.
> For the raison d'être, see: https://bugs.gentoo.org/843875
> 

> Check out the eclass here: https://gitweb.gentoo.org/repo/proj/guru.git/tree/eclass/shell-completion.eclass
> 

> I hereby ask for a code review and to add this eclass to the ::gentoo repository.
> 

> I offer to continue maintaining the eclass and Florian Schmaus (Flow) offered to co-maintain the eclass.
> 

> Please let me know your thoughts about this.

[-- Attachment #1.1.2.1: Type: text/html, Size: 8900 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: shell-completion.patch --]
[-- Type: text/x-patch; filename="shell-completion.patch"; name="shell-completion.patch", Size: 3091 bytes --]

From: Jonas Frei <freijon@pm.me>
Date:   Fri Jul 14 11:13:14 2023 +0200
Subject: shell-completion.eclass

shell-completion.eclass: Add new eclass
    
Signed-off-by: Jonas Frei <freijon@pm.me>
diff --git a/eclass/shell-completion.eclass b/eclass/shell-completion.eclass
new file mode 100644
index 000000000000..b7b59802a5f7
--- /dev/null
+++ b/eclass/shell-completion.eclass
@@ -0,0 +1,114 @@
+# Copyright 2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: shell-completion.eclass
+# @SUPPORTED_EAPIS: 8
+# @PROVIDES: bash-completion-r1
+# @AUTHOR:
+# Alfred Wingate <parona@protonmail.com>
+# @MAINTAINER:
+# Jonas Frei <freijon@pm.me>
+# @BLURB: a few quick functions to install various shell completion files
+# @DESCRIPTION:
+# This eclass provides a standardised way to install shell completions
+# for popular shells.  It inherits the already widely adopted
+# 'bash-completion-r1', thus extending on its functionality.
+
+case ${EAPI} in
+	8) ;;
+	*) die "${ECLASS}: EAPI ${EAPI:-0} not supported"
+esac
+
+if [[ ! ${_SHELL_COMPLETION_ECLASS} ]]; then
+_SHELL_COMPLETION_ECLASS=1
+
+# Extend bash-completion-r1
+inherit bash-completion-r1
+
+# @FUNCTION: _shell-completion_get_fishcompdir
+# @INTERNAL
+# @RETURN: unprefixed fish completions directory
+_shell-completion_get_fishcompdir() {
+	echo "/usr/share/fish/vendor_completions.d"
+}
+
+# @FUNCTION: _shell-completion_get_zshcompdir
+# @INTERNAL
+# @RETURN: unprefixed zsh completions directory
+_shell-completion_get_zshcompdir() {
+	echo "/usr/share/zsh/site-functions"
+}
+
+# @FUNCTION: get_fishcompdir
+# @RETURN: the fish completions directory (with EPREFIX)
+get_fishcompdir() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	echo "${EPREFIX}$(_shell-completion_get_fishcompdir)"
+}
+
+# @FUNCTION: get_zshcompdir
+# @RETURN: the zsh completions directory (with EPREFIX)
+get_zshcompdir() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	echo "${EPREFIX}$(_shell-completion_get_zshcompdir)"
+}
+
+# @FUNCTION: dofishcomp
+# @USAGE: <file...>
+# @DESCRIPTION:
+# Install fish completion files passed as args.
+dofishcomp() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	(
+		insopts -m 0644
+		insinto "$(_shell-completion_get_fishcompdir)"
+		doins "${@}"
+	)
+}
+
+# @FUNCTION: dozshcomp
+# @USAGE: <file...>
+# @DESCRIPTION:
+# Install zsh completion files passed as args.
+dozshcomp() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	(
+		insopts -m 0644
+		insinto "$(_shell-completion_get_zshcompdir)"
+		doins "${@}"
+	)
+}
+
+# @FUNCTION: newfishcomp
+# @USAGE: <file> <newname>
+# @DESCRIPTION:
+# Install fish file under a new name.
+newfishcomp() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	(
+		insopts -m 0644
+		insinto "$(_shell-completion_get_fishcompdir)"
+		newins "${@}"
+	)
+}
+
+# @FUNCTION: newzshcomp
+# @USAGE: <file> <newname>
+# @DESCRIPTION:
+# Install zsh file under a new name.
+newzshcomp() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	(
+		insopts -m 0644
+		insinto "$(_shell-completion_get_zshcompdir)"
+		newins "${@}"
+	)
+}
+
+fi

[-- Attachment #1.3: publickey - freijon@pm.me - 0x259C4FF5.asc --]
[-- Type: application/pgp-keys, Size: 3068 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 855 bytes --]

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-07-14  9:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-11 12:36 [gentoo-dev] shell-completion.eclass freijon
2023-07-14  9:44 ` [gentoo-dev] shell-completion.eclass freijon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox