Skip to content

Commit

Permalink
Add abbr attribute for flag, param, option and disp helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
ko1nksm committed Nov 3, 2020
1 parent e34a67e commit 0c4fa3c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ They are available only in the `getoptions` and `getoptions_help` functions.
- switches (SWITCH)
- Options
- attributes (KEY-VALUE)
- `abbr`:BOOLEAN - Enable the abbreviated option
- `counter`:BOOLEAN - Counts the number of flags
- `export`:BOOLEAN - Export variables
- `hidden`:BOOLEAN - Do not display in help
Expand All @@ -478,6 +479,7 @@ They are available only in the `getoptions` and `getoptions_help` functions.
- switches (SWITCH)
- Options
- attributes (KEY-VALUE)
- `abbr`:BOOLEAN - Enable the abbreviated option
- `export`:BOOLEAN - Export variables
- `hidden`:BOOLEAN - Do not display in help
- `init`:[@INIT-VALUE | =STRING | CODE] - Initial value
Expand All @@ -497,6 +499,7 @@ They are available only in the `getoptions` and `getoptions_help` functions.
- switches (SWITCH)
- Options
- attributes (KEY-VALUE)
- `abbr`:BOOLEAN - Enable the abbreviated option
- `export`:BOOLEAN - Export variables
- `hidden`:BOOLEAN - Do not display in help
- `init`:[@INIT-VALUE | =STRING | CODE] - Initial value
Expand All @@ -518,6 +521,7 @@ They are available only in the `getoptions` and `getoptions_help` functions.
- switches (SWITCH)
- Options
- attributes (KEY-VALUE)
- `abbr`:BOOLEAN - Enable the abbreviated option
- `hidden`:BOOLEAN - Do not display in help
- `label`:STRING - Option part of help message
- message (STRING)
Expand Down
4 changes: 2 additions & 2 deletions lib/getoptions_abbr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ getoptions_abbr() {
_3 'esac'
}
args() {
hidden=''
abbr=1
shift
for i; do
case $i in
--) break ;;
[!-+]*) eval "${i%%:*}=\${i#*:}"
esac
done
[ "$hidden" ] && return 0
[ "$abbr" ] || return 0

for i; do
case $i in
Expand Down
6 changes: 3 additions & 3 deletions spec/getoptions_abbr_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ Describe "getoptions_abbr()"
End
End

Context "when hide attribute specified"
Context "when abbr attribute not specified"
parser_definition() {
setup ARGS abbr:true
flag FLAG --flag -- hidden
param PARAM --param hidden:true
flag FLAG --flag -- abbr:
param PARAM --param abbr:
}

It "does not treat as an abbreviation option"
Expand Down

0 comments on commit 0c4fa3c

Please sign in to comment.