Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joubertredrat/bash-args
Bash Args is a simple way for get arguments in your bash script.
https://github.com/joubertredrat/bash-args
bash bash-prompt bash-script bash-scripting shell terminal
Last synced: 15 days ago
JSON representation
Bash Args is a simple way for get arguments in your bash script.
- Host: GitHub
- URL: https://github.com/joubertredrat/bash-args
- Owner: joubertredrat
- License: mit
- Created: 2018-12-19T17:10:46.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2018-12-19T18:46:02.000Z (almost 6 years ago)
- Last Synced: 2024-08-02T05:11:49.048Z (3 months ago)
- Topics: bash, bash-prompt, bash-script, bash-scripting, shell, terminal
- Language: Shell
- Size: 2.93 KB
- Stars: 7
- Watchers: 0
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Bash Args
Bash Args is a simple way for get arguments in your bash script.#### Install
Download this repo tarball or on releases page and include lib like on example below.
```bash
#!/bin/bashsource $(pwd)/lib/args.sh
```#### Usage
For use this script, you define what argument name and variable that will receive value, like example below.
```bash
my_key=$(bash_args_get_value "my-amazing-secret-key" "$@")
echo $my_key
```After this, if you inform param in your script, the value will be assigned on variable.
Bash args support this argument formats.
```bash
./myscript -my-amazing-secret-key value
./myscript -my-amazing-secret-key=value
./myscript --my-amazing-secret-key value
./myscript --my-amazing-secret-key=value
```#### Tests
For testing, [bats](https://github.com/sstephenson/bats) is required.
```bash
cd tests
bats main.bats
```