108 lines
4.0 KiB
Diff
108 lines
4.0 KiB
Diff
From 7b6fb980a8cddd2c405a73d7be0967e884ab0410 Mon Sep 17 00:00:00 2001
|
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
Date: Tue, 26 Aug 2025 21:30:23 +0100
|
|
Subject: [PATCH] server: Document --long-options and --short-options
|
|
|
|
These command line options can be used to list the short (ie. single
|
|
letter) and long options supported by nbdkit. They are used
|
|
internally to implement bash completions. For example:
|
|
|
|
$ nbdkit --short-options
|
|
-4
|
|
-6
|
|
-D
|
|
-e
|
|
[etc]
|
|
|
|
Previously they were undocumented and hidden from the --help output,
|
|
and did not even appear in the output of 'nbdkit --long-options'.
|
|
|
|
However the options have been around for a long time and aren't going
|
|
anywhere, and have a well-defined interface and scoped usage, so we
|
|
can safely document them. They can also be used to find out what
|
|
options are supported by a particular build of nbdkit (see subsequent
|
|
commit).
|
|
---
|
|
docs/nbdkit.pod | 14 ++++++++++++++
|
|
docs/synopsis.txt | 10 +++++-----
|
|
server/main.c | 7 ++-----
|
|
3 files changed, 21 insertions(+), 10 deletions(-)
|
|
|
|
diff --git a/docs/nbdkit.pod b/docs/nbdkit.pod
|
|
index 82939e88..bf6788bb 100644
|
|
--- a/docs/nbdkit.pod
|
|
+++ b/docs/nbdkit.pod
|
|
@@ -338,6 +338,13 @@ L<nbdkit_error(3)> or L<nbdkit_verror(3)>.
|
|
Debug messages (I<-v>/I<--verbose>) always go to standard error and
|
|
are never sent to the system log.
|
|
|
|
+=item B<--long-options>
|
|
+
|
|
+List the long command line options (those starting with I<-->)
|
|
+supported by this build of nbdkit. The options are listed one per
|
|
+line, and then nbdkit exits. This is used mainly to implement tab
|
|
+completion. See also I<--short-options>.
|
|
+
|
|
=item B<--mask-handshake=>MASK
|
|
|
|
This option can be used to mask off particular global features which
|
|
@@ -466,6 +473,13 @@ that the socket and filesystem labels are different.
|
|
nbdkit -U /tmp/sock --selinux-label=system_u:object_r:svirt_socket_t:s0 ...
|
|
chcon system_u:object_r:svirt_image_t:s0 /tmp/sock
|
|
|
|
+=item B<--short-options>
|
|
+
|
|
+List the short command line options (single letter options starting
|
|
+with I<->) supported by this build of nbdkit. The options are listed
|
|
+one per line, and then nbdkit exits. This is used mainly to implement
|
|
+tab completion. See also I<--long-options>.
|
|
+
|
|
=item B<-s>
|
|
|
|
=item B<--single>
|
|
diff --git a/docs/synopsis.txt b/docs/synopsis.txt
|
|
index 0d25c42d..3cc620db 100644
|
|
--- a/docs/synopsis.txt
|
|
+++ b/docs/synopsis.txt
|
|
@@ -4,14 +4,14 @@ nbdkit [-4|--ipv4-only] [-6|--ipv6-only]
|
|
[--filter=FILTER ...] [-f|--foreground]
|
|
[-g|--group GROUP] [-i|--ipaddr IPADDR] [--keepalive]
|
|
[--log=default|stderr|syslog|null|/path]
|
|
- [--mask-handshake=MASK] [--name=NAME] [-n|--newstyle]
|
|
- [--no-mc|--no-meta-contexts]
|
|
+ [--long-options] [--mask-handshake=MASK] [--name=NAME]
|
|
+ [-n|--newstyle] [--no-mc|--no-meta-contexts]
|
|
[--no-sr|--no-structured-replies] [-o|--oldstyle]
|
|
[-P|--pidfile PIDFILE] [-p|--port PORT] [--print-uri]
|
|
[-r|--readonly] [--run 'COMMAND ARGS ...']
|
|
- [--selinux-label=LABEL] [-s|--single] [--swap]
|
|
- [-t|--threads THREADS] [--timeout=TIMEOUT]
|
|
- [--tls=off|on|require]
|
|
+ [--selinux-label=LABEL] [--short-options]
|
|
+ [-s|--single] [--swap] [-t|--threads THREADS]
|
|
+ [--timeout=TIMEOUT] [--tls=off|on|require]
|
|
[--tls-certificates=/path/to/certificates]
|
|
[--tls-psk=/path/to/pskfile] [--tls-verify-peer]
|
|
[-U|--unix SOCKET|-] [-u|--user USER]
|
|
diff --git a/server/main.c b/server/main.c
|
|
index 91e3172b..ad0e5abe 100644
|
|
--- a/server/main.c
|
|
+++ b/server/main.c
|
|
@@ -404,11 +404,8 @@ main (int argc, char *argv[])
|
|
break;
|
|
|
|
case LONG_OPTIONS_OPTION:
|
|
- for (i = 0; long_options[i].name != NULL; ++i) {
|
|
- if (strcmp (long_options[i].name, "long-options") != 0 &&
|
|
- strcmp (long_options[i].name, "short-options") != 0)
|
|
- printf ("--%s\n", long_options[i].name);
|
|
- }
|
|
+ for (i = 0; long_options[i].name != NULL; ++i)
|
|
+ printf ("--%s\n", long_options[i].name);
|
|
cleanup_random_fifo ();
|
|
exit (EXIT_SUCCESS);
|
|
|
|
--
|
|
2.47.1
|
|
|