comparison sbin/fports @ 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 31ff8e5efdd6
children b59054f11029
comparison
equal deleted inserted replaced
803:2cd233b137ec 804:f406b3b76b62
19 # shellcheck disable=SC2034 # VERSION appears unused 19 # shellcheck disable=SC2034 # VERSION appears unused
20 VERSION='@@VERSION@@' 20 VERSION='@@VERSION@@'
21 21
22 # shellcheck disable=SC2016 # no expansion 22 # shellcheck disable=SC2016 # no expansion
23 USAGE=' 23 USAGE='
24 USAGE: fports -h 24 USAGE: fports -h|--help
25 fports -V 25 fports -V|--version
26 fports deptree [-l maxlevel] [-r] [-t] package... 26 fports deptree [-l maxlevel|--maxlevel=maxlevel] [-r|--reverse] [-t|--list|--transitive] package...
27 fports detail -n 27 fports detail -n|--noauto|--no-auto
28 fports detail -m 28 fports detail -m|--mapped
29 fports detail package... 29 fports detail package...
30 30
31 GLOBAL OPTIONS: 31 GLOBAL OPTIONS:
32 32
33 -V Print the program name and version number to stdout and exit 33 -V, --version Print the program name and version number to stdout and exit.
34 34
35 -h Print this help message to stdout and exit 35 -h, --help Print this help message to stdout and exit.
36 36
37 ' 37 '
38 38
39 39
40 _p_datadir='@@DATADIR@@' 40 _p_datadir='@@DATADIR@@'
75 local opt 75 local opt
76 76
77 opt_maxlevel=0 77 opt_maxlevel=0
78 opt_reversed=no 78 opt_reversed=no
79 opt_flat=no 79 opt_flat=no
80 while getopts "l:rt" opt; do 80 while getopts "l:rt-:" opt; do
81 postprocess_getopts_for_long "l:rt-:" opt "maxlevel=" "reverse" "list" "transitive" ""
81 case "${opt}" in 82 case "${opt}" in
82 l) 83 l|maxlevel)
83 opt_maxlevel=$(($OPTARG + 0));; 84 opt_maxlevel=$(($OPTARG + 0));;
84 r) 85 r|reverse)
85 # shellcheck disable=SC2034 86 # shellcheck disable=SC2034
86 opt_reversed=yes;; 87 opt_reversed=yes;;
87 t) 88 t|list|transitive)
88 opt_flat=yes;; 89 opt_flat=yes;;
89 \?) 90 \?)
90 exit 2;; 91 exit 2;;
91 *) 92 *)
92 fatal 2 "option handling failed";; 93 fatal 2 "option handling failed";;
353 repo title_printed indexfile _dummy opt acookie \ 354 repo title_printed indexfile _dummy opt acookie \
354 pkglabel pkgdescr pkgversion mapped_package 355 pkglabel pkgdescr pkgversion mapped_package
355 356
356 opt_noauto=no 357 opt_noauto=no
357 opt_mapped=no 358 opt_mapped=no
358 while getopts "nm" opt; do 359 while getopts "nm-:" opt; do
360 postprocess_getopts_for_long "nm-:" opt "noauto" "no-auto" "mapped" ""
359 case "${opt}" in 361 case "${opt}" in
360 n) 362 n|noauto|no-auto)
361 # shellcheck disable=SC2034 # appears unused 363 # shellcheck disable=SC2034 # appears unused
362 opt_noauto=yes;; 364 opt_noauto=yes;;
363 m) 365 m|mapped)
364 # shellcheck disable=SC2034 # appears unused 366 # shellcheck disable=SC2034 # appears unused
365 opt_mapped=yes;; 367 opt_mapped=yes;;
366 \?) 368 \?)
367 exit 2;; 369 exit 2;;
368 *) 370 *)
591 593
592 594
593 # 595 #
594 # Global option handling 596 # Global option handling
595 # 597 #
596 while getopts "Vh" _opt ; do 598 while getopts "Vh-:" _opt ; do
599 postprocess_getopts_for_long "Vh-:" _opt "version" "help" ""
597 case "${_opt}" in 600 case "${_opt}" in
598 V) 601 V|version)
599 printf 'fports %s\n' '@@SIMPLEVERSIONSTR@@' 602 printf 'fports %s\n' '@@SIMPLEVERSIONSTR@@'
600 exit 0 603 exit 0
601 ;; 604 ;;
602 h) 605 h|help)
603 echo "${USAGE}" 606 echo "${USAGE}"
604 exit 0 607 exit 0
605 ;; 608 ;;
606 \?) 609 \?)
607 exit 2; 610 exit 2;