[sdk/kdesrc-build] /: Add --show-options-specifiers option

Andrew Shark null at kde.org
Mon Jan 15 17:27:50 GMT 2024


Git commit 35e68fb5b925ef438cf441ead6dce3285f0fdbc8 by Andrew Shark.
Committed on 15/01/2024 at 18:23.
Pushed by ashark into branch 'master'.

Add --show-options-specifiers option

M  +8    -8    doc/supported-cmdline-params.docbook
M  +9    -10   modules/ksb/Cmdline.pm

https://invent.kde.org/sdk/kdesrc-build/-/commit/35e68fb5b925ef438cf441ead6dce3285f0fdbc8

diff --git a/doc/supported-cmdline-params.docbook b/doc/supported-cmdline-params.docbook
index 71993bdc..219c9099 100644
--- a/doc/supported-cmdline-params.docbook
+++ b/doc/supported-cmdline-params.docbook
@@ -704,14 +704,6 @@ Display the program version.
 </para></listitem>
 </varlistentry>
 
-<varlistentry id="cmdline-author">
-<term><option>--author</option></term>
-<listitem><para>
-Display contact information for the
-author.
-</para></listitem>
-</varlistentry>
-
 <varlistentry id="cmdline-help">
 <term><option>--help</option> (or <option>-h</option>)</term>
 <listitem><para>
@@ -728,6 +720,14 @@ prove useful in bug reports or when asking for help in forums or mailing lists.
 </listitem>
 </varlistentry>
 
+<varlistentry id="cmdline-show-options-specifiers">
+<term><option>--show-options-specifiers</option></term>
+<listitem><para>
+Print the specifier lines (in the format that GetOpts::Long accepts) for all command line options supported by the script.
+This may be used by developers, for example, for generating zsh autocompletion functions.
+</para></listitem>
+</varlistentry>
+
 </variablelist>
 
 </sect2>
diff --git a/modules/ksb/Cmdline.pm b/modules/ksb/Cmdline.pm
index b11dc63a..2422cd83 100644
--- a/modules/ksb/Cmdline.pm
+++ b/modules/ksb/Cmdline.pm
@@ -142,7 +142,7 @@ sub readCommandLineOptionsAndSelectors (@options)
     %foundOptions = (
         'show-info' => sub { _showInfoAndExit();    },
         version     => sub { _showVersionAndExit(); },
-        author      => sub { _showAuthorAndExit();  },
+        'show-options-specifiers' => sub { _showOptionsSpecifiersAndExit(); },
         help        => sub { _showHelpAndExit();    },
 
         # Intended as a short option, -d would imply --include-dependencies and
@@ -399,17 +399,16 @@ sub _showInfoAndExit
     exit;
 }
 
-sub _showAuthorAndExit
+sub _showOptionsSpecifiersAndExit
 {
-    my $version = "kdesrc-build " . scriptVersion();
-    say <<~DONE;
-        $version was written (mostly) by:
-          Michael Pyne <mpyne\@kde.org>
+    my @supportedOptions = _supportedOptions();
 
-        Many people have contributed code, bugfixes, and documentation.
+    # The initial setup options are handled outside of Cmdline (in the starting script).
+    my @initial_options = ("initial-setup", "install-distro-packages", "generate-config", "update-shellrc");
 
-        Please report bugs using the KDE Bugzilla, at https://bugs.kde.org/
-        DONE
+    foreach my $option (@supportedOptions, @initial_options) {
+        print "$option\n";
+    }
 
     exit;
 }
@@ -420,7 +419,6 @@ sub _supportedOptions
     # See https://perldoc.perl.org/5.005/Getopt::Long for options specification format
 
     my @non_context_options = (
-        'author',
         'build-only',
         'dependency-tree',
         'dependency-tree-fullpath',
@@ -441,6 +439,7 @@ sub _supportedOptions
         'resume-from|from|f=s',
         'set-module-option-value=s',
         'show-info',
+        'show-options-specifiers',
         'src-only|s',
         'start-program|run=s{,}',
         'stop-after|to=s',


More information about the kde-doc-english mailing list