Github messages for voidlinux
 help / color / mirror / Atom feed
From: maxice8 <maxice8@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] startup: add completion for fish shell
Date: Mon, 06 Sep 2021 09:35:32 +0200	[thread overview]
Message-ID: <20210906073532.rstUJ1xfAbfNHJwDKRus-_fqixiROP4H_QeU1QtfanM@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-32854@inbox.vuxu.org>

[-- Attachment #1: Type: text/plain, Size: 396 bytes --]

There is an updated pull request by maxice8 against master on the void-packages repository

https://github.com/maxice8/void-packages startup
https://github.com/void-linux/void-packages/pull/32854

startup: add completion for fish shell
upstream: https://gitlab.com/chinstrap/startup/-/merge_requests/41


A patch file from https://github.com/void-linux/void-packages/pull/32854.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-startup-32854.patch --]
[-- Type: text/x-diff, Size: 12061 bytes --]

From 2305450b6df70eb38d498551a64be950f9e74c89 Mon Sep 17 00:00:00 2001
From: Leo <thinkabit.ukim@gmail.com>
Date: Mon, 6 Sep 2021 07:14:57 +0000
Subject: [PATCH] startup: add completion for fish shell

upstream: https://gitlab.com/chinstrap/startup/-/merge_requests/41
---
 srcpkgs/startup/files/init-checkconf.fish  |   7 ++
 srcpkgs/startup/files/initctl.fish         | 125 +++++++++++++++++++++
 srcpkgs/startup/files/startup-monitor.fish |   5 +
 srcpkgs/startup/files/startup.fish         |  17 +++
 srcpkgs/startup/template                   |   9 +-
 5 files changed, 162 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/startup/files/init-checkconf.fish
 create mode 100644 srcpkgs/startup/files/initctl.fish
 create mode 100644 srcpkgs/startup/files/startup-monitor.fish
 create mode 100644 srcpkgs/startup/files/startup.fish

diff --git a/srcpkgs/startup/files/init-checkconf.fish b/srcpkgs/startup/files/init-checkconf.fish
new file mode 100644
index 000000000000..d14b4b4b7054
--- /dev/null
+++ b/srcpkgs/startup/files/init-checkconf.fish
@@ -0,0 +1,7 @@
+# Global options
+complete -f -c init-checkconf -s d -l debug -d 'Show some debug output'
+complete -r -F -c init-checkconf -s f -l file -d 'Path to job configuration file to check'
+complete -r -F -c init-checkconf -s i -l initctl-path -d 'Path to initctl(8) binary'
+complete -f -c init-checkconf -s s -l noscript -d 'Do not check script sections'
+complete -r -F -c init-checkconf -s x -l startup-path -d 'Payh to startup(8) binary'
+complete -f -c init-checkconf -s h -l help -d 'Display usage statement'
diff --git a/srcpkgs/startup/files/initctl.fish b/srcpkgs/startup/files/initctl.fish
new file mode 100644
index 000000000000..0c5cc8a3445f
--- /dev/null
+++ b/srcpkgs/startup/files/initctl.fish
@@ -0,0 +1,125 @@
+# Global options
+complete -f -c initctl -l session -d 'Use existing session D-Bus session (for testing)'
+complete -f -c initctl -l system -d 'Use system D-Bus'
+complete -x -c initctl -l dest -d 'Name for the Startup daemon in system D-Bus'
+complete -f -c initctl -l user -d 'Run in user mode'
+complete -f -c initctl -s q -l quiet -d 'Only output errors'
+complete -f -c initctl -s v -l verbose -d 'Include informational messages'
+complete -f -c initctl -l help -d 'Show help'
+complete -f -c initctl -l version -d 'Output version information'
+
+# Job commands
+complete -f -c initctl -n __fish_use_subcommand -a start -d 'Start job'
+complete -f -c initctl -n __fish_use_subcommand -a stop -d 'Stop job'
+complete -f -c initctl -n __fish_use_subcommand -a restart -d 'Restart job'
+complete -f -c initctl -n __fish_use_subcommand -a reload -d 'Reload job'
+complete -f -c initctl -n __fish_use_subcommand -a status -d 'Query status of job'
+complete -f -c initctl -n __fish_use_subcommand -a list -d 'List known jobs'
+
+# Event commands
+complete -f -c initctl -n __fish_use_subcommand -a emit -d 'Emit an event'
+
+# Environment commands
+complete -f -c initctl -n __fish_use_subcommand -a get-env -d 'Retrieve value of a job environment variable'
+complete -f -c initctl -n __fish_use_subcommand -a list-env -d 'Show all job environment variables'
+complete -f -c initctl -n __fish_use_subcommand -a reset-env -d 'Revert all job environment variable changes'
+complete -f -c initctl -n __fish_use_subcommand -a set-env -d 'Set one or more job environment variables'
+complete -f -c initctl -n __fish_use_subcommand -a unset-env -d 'Remove one or more job environment variables'
+
+# Other commands
+complete -f -c initctl -n __fish_use_subcommand -a reload-configuration -d 'Reload init daemon configuration'
+complete -f -c initctl -n __fish_use_subcommand -a version -d 'Request version of the init daemon'
+complete -f -c initctl -n __fish_use_subcommand -a log-priority -d 'Change minimum priority of log messages from init daemon'
+complete -f -c initctl -n __fish_use_subcommand -a show-config -d 'Show emits, start on and stop on defaults for a job'
+complete -f -c initctl -n __fish_use_subcommand -a check-config -d 'Check for unreachable jobs/event conditions'
+complete -f -c initctl -n __fish_use_subcommand -a usage -d 'Show job usage message if available'
+complete -f -c initctl -n __fish_use_subcommand -a notify-cgroup-manager-address -d 'Inform Upstart of D-Bus address cgroup manager is available on'
+complete -f -c initctl -n __fish_use_subcommand -a notify-dbus-address -d 'Inform Upstart of D-Bus address to connect to'
+complete -f -c initctl -n __fish_use_subcommand -a notify-disk-writeable -d 'Inform Upstart that disk is now writeable'
+complete -f -c initctl -n __fish_use_subcommand -a list-sessions -d 'List all sessions'
+complete -f -c initctl -n __fish_use_subcommand -a re-exec -d 'Perform stateful re-exec'
+complete -f -c initctl -n __fish_use_subcommand -a help -d 'Display list of commands'
+
+# -n|--no-wait for some of the Job commands
+complete -f -c initctl -n "__fish_seen_subcommand_from start stop restart emit" -s n -l no-wait -d 'Do not wait for action to return'
+
+# -r|--retain for some of the Environment commands
+complete -f -c initctl -n "__fish_seen_subcommand_from set-env unset-env reset-env" -s r -l retain -d 'Do not modify already set variables'
+
+# Offer all 'stop/waiting' jobs with 'start' subcommand
+complete -f -c initctl -n "__fish_seen_subcommand_from start" -a "(__fish_initctl_run list | string match --entire stop/waiting | string split ' ' -f 1)" -d Job
+
+# Offer all 'start/*' jobs with 'stop', 'reload' and 'restart' subcommands
+complete -f -c initctl -n "__fish_seen_subcommand_from stop reload restart" -a "(__fish_initctl_run list | string match --entire start/running | string split ' ' -f 1)" -d Job
+
+# Offer all jobs with its status to the 'status' subcommand
+complete -f -c initctl -n "__fish_seen_subcommand_from status" -a "(__fish_initctl_list_with_status)"
+
+# Offer all jobs to the 'check-config' subcommand
+complete -f -c initctl -n "__fish_seen_subcommand_from check-config" -a "(__fish_initctl_run list | string split ' ' -f 1)" -d Job
+
+# Offer all envs from 'list-env' subcommand to 'get-env' and 'unset-env'
+complete -f -c initctl -n "__fish_seen_subcommand_from get-env unset-env" -a "(__fish_initctl_run list-env | string replace -r '=' '\tVariable: ')"
+
+# Possible priority levels for 'log-priority' subcommand
+complete -f -c initctl -n "__fish_seen_subcommand_from log-priority" -a "debug info message warn error fatal" -d 'Priority'
+
+# -e|--enumerate option for 'show-config' subcommand
+complete -f -c initctl -n "__fish_seen_subcommand_from show-config" -s e -l enumerate -d 'Print per line each "start on" and "stop on" condition for each event or job'
+
+# -i|--ignore-events and -w|--warn for 'check-config' subcommand
+complete -x -c initctl -n "__fish_seen_subcommand_from check-config" -s i -l ignore-events -d 'Comma-separated list of events to ignore'
+complete -f -c initctl -n "__fish_seen_subcommand_from check-config" -s w -l warn -d 'treat any unknown jobs and events as errors'
+
+# Show all the events from 'emits' in configuration to emit
+complete -x -c initctl -n "__fish_seen_subcommand_from emit" -a "(__fish_initctl_get_events)" -d 'Event'
+
+function __fish_initctl_context -d 'Get the current startup context based on the commandline'
+	if __fish_seen_argument -l user
+		echo -- user
+	else if __fish_seen_argument -l session
+		echo -- session
+	else if __fish_seen_argument -l system
+		echo -- system
+	else if set -q UPSTART_SESSION
+		echo -- user
+	else
+		echo -- system
+	end
+end
+
+function __fish_initctl_run -d 'Run initctl with the appropriate context'
+	initctl --(__fish_initctl_context) $argv
+end
+
+function __fish_initctl_list_with_status -d 'Get Job and status from initctl'
+	__fish_initctl_run list \
+		| cut -d ' ' -f 1-2 \
+		| string replace -r ',$' '' \
+		| string replace -r ' ' '\tJob: '
+end
+
+function __fish_initctl_extract_events -d 'Extract emitted events from job configuration'
+	grep -E '^[[:space:]]*emits ' $argv/*.conf \
+	| cut -d : -f 2- \
+	| string replace 'emit ' '' \
+	| string replace ' ' \n \
+	| sort -u
+end
+
+function __fish_initctl_get_events -d 'Print all events that jobs in the current context emit'
+	switch (__fish_initctl_context)
+		case system
+			set -l dirs /etc/startup /etc/init /usr/share/start /usr/share/xdg/startup
+			for d in (string replace : ' ' $XDG_CONFIG_DIRS)
+				set -l dirs $dirs $d/startup $d/upstart
+			end
+			__fish_initctl_extract_events $dirs
+		case user session
+			if set -q XDG_CONFIG_HOME
+				__fish_initctl_extract_events $XDG_CONFIG_HOME/startup $XDG_CONFIG_HOME/upstart
+			else
+				__fish_initctl_extract_events $HOME/.config/startup $HOME/.config/upstart
+			end
+	end
+end
diff --git a/srcpkgs/startup/files/startup-monitor.fish b/srcpkgs/startup/files/startup-monitor.fish
new file mode 100644
index 000000000000..70fa34ea29cb
--- /dev/null
+++ b/srcpkgs/startup/files/startup-monitor.fish
@@ -0,0 +1,5 @@
+# Global options
+complete -x -c startup-monitor -s d -l destination -d 'Which endpoint to connect to' -a "session-socket session-system system-socket system-bus"
+complete -f -c startup-monitor -s h -l help -d 'Show brief usage summary'
+complete -f -c startup-monitor -s n -l no-gui -d 'Run in command-line mode'
+complete -x -c startup-monitor -s s -l separator -d 'Specify alternate field separator for command-line output'
diff --git a/srcpkgs/startup/files/startup.fish b/srcpkgs/startup/files/startup.fish
new file mode 100644
index 000000000000..56b0313cc1b1
--- /dev/null
+++ b/srcpkgs/startup/files/startup.fish
@@ -0,0 +1,17 @@
+# Options
+complete -r -F -c startup -l append-confdir -d 'Append directories to look for job configuration files'
+complete -r -F -c startup -l confdir -d 'Read job configurationo files from this directory rather than defaults'
+complete -x -c startup -l default-console -d 'Default value for "console" stanza'
+complete -f -c startup -l no-cgroups -d 'Do not honour cgroup stanza'
+complete -f -c startup -l no-dbus -d 'Do connect to a D-Bus bus'
+complete -f -c startup -l no-inherint-env -d 'Stop jobs from inheriting initial environment'
+complete -r -F -c startup -l logdir -d 'Write job output log files to this directory'
+complete -f -c startup -l no-log -d 'Disable logging of job output'
+complete -f -c startup -l no-session -d 'Disable chroot sessions'
+complete -f -c startup -l no-startup-event -d 'Do not emit initial startup event'
+complete -r -F -c startup -l prepend-confdir -d 'Prepend directories to look for job configuration files'
+complete -f -c startup -l session -d 'Connect to the D-Bus session bus'
+complete -x -c startup -l startup-event -d 'emit a different event at startup than the default one'
+complete -f -c starutp -s q -l quiet -d 'Only output errors'
+complete -f -c startup -s v -l verbose -d 'Output verbose messages about job state changes and event emissions'
+complete -f -c startup -l version -d 'Output version information and exit'
diff --git a/srcpkgs/startup/template b/srcpkgs/startup/template
index eeeee53501a1..8f38967e26da 100644
--- a/srcpkgs/startup/template
+++ b/srcpkgs/startup/template
@@ -1,7 +1,7 @@
 # Template file for 'startup'
 pkgname=startup
 version=2.0.2
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--disable-sysvcompat --disable-dconf-bridge --disable-cgroups"
 make_dirs="/var/log/startup 0750 root adm"
@@ -22,6 +22,12 @@ pre_configure() {
 
 post_install() {
 	rm -f -- "${DESTDIR}/usr/lib/libupstart.la"
+
+	# Fish completion
+	vinstall ${FILESDIR}/startup.fish 0644 /usr/share/fish/completions
+	vinstall ${FILESDIR}/initctl.fish 0644 /usr/share/fish/completions
+	vinstall ${FILESDIR}/init-checkconf.fish 0644 /usr/share/fish/completions
+	vinstall ${FILESDIR}/startup-monitor.fish 0644 /usr/share/fish/completions
 }
 
 startup-tools_package() {
@@ -33,6 +39,7 @@ startup-tools_package() {
 		vmove usr/share/icons
 		vmove usr/share/applications
 		vmove usr/share/man/man8/startup-monitor.8
+		vmove usr/share/fish/completions/startup-monitor.fish
 	}
 }
 

  reply	other threads:[~2021-09-06  7:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-06  7:17 [PR PATCH] " maxice8
2021-09-06  7:35 ` maxice8 [this message]
2021-09-06 23:20 ` [PR PATCH] [Updated] " maxice8
2021-09-14  3:43 ` maxice8
2021-09-14  3:50 ` maxice8
2021-10-08 16:54 ` [PR PATCH] [Closed]: " Chocimier
2021-10-08 16:54 ` Chocimier

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

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

  git send-email \
    --in-reply-to=20210906073532.rstUJ1xfAbfNHJwDKRus-_fqixiROP4H_QeU1QtfanM@z \
    --to=maxice8@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /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.
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 NNTP newsgroup(s).