Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] startup: add completion for fish shell
@ 2021-09-06  7:17 maxice8
  2021-09-06  7:35 ` [PR PATCH] [Updated] " maxice8
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: maxice8 @ 2021-09-06  7:17 UTC (permalink / raw)
  To: ml

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

There is a new 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: 10990 bytes --]

From 95f4d63e7711f47e1bfde336cffa3599485cc7d6 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.fish        |  17 +++
 srcpkgs/startup/template                  |   7 +-
 4 files changed, 155 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.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.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..d22228ecea90 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,11 @@ 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
 }
 
 startup-tools_package() {

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

end of thread, other threads:[~2021-10-08 16:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-06  7:17 [PR PATCH] startup: add completion for fish shell maxice8
2021-09-06  7:35 ` [PR PATCH] [Updated] " maxice8
2021-09-06 23:20 ` maxice8
2021-09-14  3:43 ` maxice8
2021-09-14  3:50 ` maxice8
2021-10-08 16:54 ` Chocimier
2021-10-08 16:54 ` [PR PATCH] [Closed]: " Chocimier

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