This guide will walk you through setting up a simple script to use shArg and highlight some of the features of the tool.
mkdir -p "test"
cd "test"
curl -L https://raw.githubusercontent.com/hattan/shArg/main/scripts/setup.sh | bash
-
touch example.sh
-
chmod +x example.sh
-
Open example.sh in your favorite editor and the following :
#!/usr/bin/env bash # load shArg source .sh_arg/shArg.sh declare MESSAGE declare DEBUG # register arguments shArgs.arg "MESSAGE" -m --message PARAMETER true shArgs.arg "DEBUG" -d --debug FLAG true # parse inputs shArgs.parse "$@" echo "The message is $MESSAGE" if [ "$DEBUG" == true ]; then echo "DEBUG is true!" else echo "DEBUG is false" fi
- Invoke example.sh with the following commands:
./example.sh -m hello world
./example.sh -m=hello there
./example.sh -m hi -d
- See the project README.
- Explore the provided examples.