Skip to content

Commit 2832a1f

Browse files
author
Damien Nadé
committed
argsparse.sh: ARGSPARSE_COMPLETION_MODE introduction
1 parent 353d587 commit 2832a1f

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

argsparse.sh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,10 @@ argsparse_allow_no_argument() {
10301030
esac
10311031
}
10321032

1033+
if [[ $ARGSPARSE_COMPLETION_MODE ]]
1034+
then
1035+
alias argsparse_parse_options='return 0 2>/dev/null || : '
1036+
else
10331037
## @fn argsparse_parse_options()
10341038
## @brief Parse program options.
10351039
## @details This function will make option parsing happen, and if an error
@@ -1039,14 +1043,14 @@ argsparse_allow_no_argument() {
10391043
## @param parameters... should be the program arguments.
10401044
## @retval 0 if the whole option parsing process went fine.
10411045
## @retval 1 if an error is encoutered and usage does not perform an exit.
1042-
argsparse_parse_options() {
1043-
unset __argsparse_tmp_identifiers || :
1044-
__argsparse_parse_options_no_usage "$@" && return
1045-
# Something went wrong, invoke usage function, if defined.
1046-
declare -f usage >/dev/null 2>&1 && usage
1047-
return 1
1048-
}
1049-
1046+
argsparse_parse_options() {
1047+
unset __argsparse_tmp_identifiers || :
1048+
__argsparse_parse_options_no_usage "$@" && return
1049+
# Something went wrong, invoke usage function, if defined.
1050+
declare -f usage >/dev/null 2>&1 && usage
1051+
return 1
1052+
}
1053+
fi
10501054

10511055
__argsparse_parse_options_prepare_exclude() {
10521056
# Check for all "exclude" properties, and fill "exclusions"

0 commit comments

Comments
 (0)