Skip to content

Bash Args is a simple way for get arguments in your bash script.

License

Notifications You must be signed in to change notification settings

joubertredrat/bash-args

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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