Skip to content

Latest commit

 

History

History
41 lines (28 loc) · 862 Bytes

README.md

File metadata and controls

41 lines (28 loc) · 862 Bytes

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.

#!/bin/bash

source $(pwd)/lib/args.sh

Usage

For use this script, you define what argument name and variable that will receive value, like example below.

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.

./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 is required.

cd tests
bats main.bats