Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hanovruslan/bash-get-options
get options from script args
https://github.com/hanovruslan/bash-get-options
bash
Last synced: about 2 months ago
JSON representation
get options from script args
- Host: GitHub
- URL: https://github.com/hanovruslan/bash-get-options
- Owner: hanovruslan
- License: mit
- Created: 2017-08-17T03:55:16.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-04-12T07:24:05.000Z (over 6 years ago)
- Last Synced: 2024-07-01T01:59:08.414Z (3 months ago)
- Topics: bash
- Language: Shell
- Size: 8.79 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bash-get-options #
get options from script args
try
- `./main.sh`
- `./main.sh -x foo`
- `./main.sh -y bar`
- `./main.sh -x bar -y foo`
- `./main.sh -y bar -x foo`
- `./main.sh -x bar -x foo`## How to include into your script/project ##
1. `git clone` this repo
1. include line `source /path/to/this/repo/src/src.sh`
1. set up your args dict and defaultsdeclare -A options_dict=(
[x]=xvar
[y]=yvar
)
declare -A options_defaults=(
[xvar]="xvalue"
[yvar]="y1 y2 y3"
)
1. add args processing snippet and export vars into current processbgo_main ${@}
1. now you can use it as array values
echo "xvar = ${xvar[@]}"
echo "yvar = ${yvar[@]}"
for y in ${yvar[@]}
do
echo ${y}
done