changeset 804:f406b3b76b62

fports: Implemented also long commandline options
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 04 Nov 2024 11:44:47 +0100
parents 2cd233b137ec
children e18cc5fe828c
files docs/man/man8/fports.rst sbin/fports
diffstat 2 files changed, 35 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/docs/man/man8/fports.rst	Mon Nov 04 11:08:15 2024 +0100
+++ b/docs/man/man8/fports.rst	Mon Nov 04 11:44:47 2024 +0100
@@ -9,15 +9,15 @@
 Synopsis
 --------
 
-**fports -h**
+**fports**  **-h**\|\ **--help**
 
-**fports -V**
+**fports**  **-V**\|\ **--version**
 
-**fports deptree** [**-l** `maxlevel`] [**-r**] [**t**] `package` ...
+**fports deptree** [**-l** `maxlevel`\|\ **--maxlevel**\=\ `maxlevel`] [**-r**\|\ **--reverse**] [**-t**\|\ **--list**\|\ **--transitive**] `package` ...
 
-**fports detail -n**
+**fports detail**  **-n**\|\ **--noauto**\|\ **--no-auto**
 
-**fports detail -m**
+**fports detail**  **-m**\|\ **--mapped**
 
 **fports detail** `package` ...
 
@@ -42,42 +42,42 @@
 
 These global options are implemented:
 
-.. option:: -h
+.. option:: -h, --help
 
    Print a short usage message to stdout and exit.
 
-.. option:: -V
+.. option:: -V, --version
 
    Print the program name and version number to stdout and exit.
 
 
-**fports deptree** [**-l** `maxlevel`] [**-r**] [**t**] `package`...
+**fports deptree** [**-l** `maxlevel`\|\ **--maxlevel**\=\ `maxlevel`] [**-r**\|\ **--reverse**] [**-t**\|\ **--list**\|\ **--transitive**] `package` ...
 
   Print a dependency tree for every given `package`. A package tree is
   a hierarchical list of packages that `packages` depends on.
 
   .. program:: fports deptree
 
-  .. option:: -t
+  .. option:: -t, --list, --transitive
 
      Instead of printing the dependencies as tree print them as a sorted
      list. This list is the transitive closure of all dependencies.
 
-  .. option:: -l <maxlevel>
+  .. option:: -l <maxlevel>, --maxlevel=<maxlevel>
 
      Limit the output to sub-levels up to `maxlevel`. To print only
      direct dependencies use a `maxlevel` of `1`.
      Default is 0 (i.e. no limit).
 
-  .. option:: -r
+  .. option:: -r, --reverse
 
      Use reversed dependencies and print the package tree for all packages
      that depend on a given `package`.
 
 
-**fports detail -n**
+**fports detail**  **-n**\|\ **--noauto**\|\ **--no-auto**
 
-**fports detail -m**
+**fports detail**  **-m**\|\ **--mapped**
 
 **fports detail** `package` ...
 
@@ -92,11 +92,11 @@
 
   .. program:: fports deptree
 
-  .. option:: -n
+  .. option:: -n, --noauto, --no-auto
 
      Automatically select all packages that are *not* installed automatically.
 
-  .. option:: -m
+  .. option:: -m, --mapped
 
      Automatically select all packages that have a package mapping entry
      in :file:`package-mapping.conf`. See :manpage:`package-mapping.conf(5)`.
--- a/sbin/fports	Mon Nov 04 11:08:15 2024 +0100
+++ b/sbin/fports	Mon Nov 04 11:44:47 2024 +0100
@@ -21,18 +21,18 @@
 
 # shellcheck disable=SC2016    # no expansion
 USAGE='
-USAGE: fports -h
-       fports -V
-       fports deptree [-l maxlevel] [-r] [-t] package...
-       fports detail -n
-       fports detail -m
+USAGE: fports -h|--help
+       fports -V|--version
+       fports deptree [-l maxlevel|--maxlevel=maxlevel] [-r|--reverse] [-t|--list|--transitive] package...
+       fports detail -n|--noauto|--no-auto
+       fports detail -m|--mapped
        fports detail package...
 
 GLOBAL OPTIONS:
 
-  -V    Print the program name and version number to stdout and exit
+  -V, --version  Print the program name and version number to stdout and exit.
 
-  -h    Print this help message to stdout and exit
+  -h, --help     Print this help message to stdout and exit.
 
 '
 
@@ -77,14 +77,15 @@
     opt_maxlevel=0
     opt_reversed=no
     opt_flat=no
-    while getopts "l:rt" opt; do
+    while getopts "l:rt-:" opt; do
+        postprocess_getopts_for_long "l:rt-:" opt "maxlevel=" "reverse" "list" "transitive" ""
         case "${opt}" in
-            l)
+            l|maxlevel)
                 opt_maxlevel=$(($OPTARG + 0));;
-            r)
+            r|reverse)
                 # shellcheck disable=SC2034
                 opt_reversed=yes;;
-            t)
+            t|list|transitive)
                 opt_flat=yes;;
             \?)
                 exit 2;;
@@ -355,12 +356,13 @@
 
     opt_noauto=no
     opt_mapped=no
-    while getopts "nm" opt; do
+    while getopts "nm-:" opt; do
+        postprocess_getopts_for_long "nm-:" opt "noauto" "no-auto" "mapped" ""
         case "${opt}" in
-            n)
+            n|noauto|no-auto)
                 # shellcheck disable=SC2034     # appears unused
                 opt_noauto=yes;;
-            m)
+            m|mapped)
                 # shellcheck disable=SC2034     # appears unused
                 opt_mapped=yes;;
             \?)
@@ -593,13 +595,14 @@
 #
 # Global option handling
 #
-while getopts "Vh" _opt ; do
+while getopts "Vh-:" _opt ; do
+    postprocess_getopts_for_long "Vh-:" _opt "version" "help" ""
     case "${_opt}" in
-        V)
+        V|version)
             printf 'fports %s\n' '@@SIMPLEVERSIONSTR@@'
             exit 0
             ;;
-        h)
+        h|help)
             echo "${USAGE}"
             exit 0
             ;;