Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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

```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
```