After run install command, you will have xSHELL on your home and added to your system $PATH
~/bin/xSHELL
xshell Command
Within this library, comes xshell tool used create new scripts;
xshell -h
usage:
xshell [-a <arguments>] [-e <editor>] [-f <name>] [-H] [-l] [-o <output>] [-h] [-v]
-> Available Options:
-a, --args <arguments> define <arguments> for new script
-e, --editor <editor> define <editor> to open script
-f, --filename <name> filename for new script
-H, --header enable our default header on the new script
-l, --lib define new script as a our LIB type (can be loaded with 'use' function)
-o, --output <output> setup <output> directory for new script
-h, --help show this help
-v, --version print version and exit
v0.1.17-rc316 - writen by @fbnmtz 2020
xshell command above will generate this code below and open the new file on defined editor:
```bash
#!/usr/bin/env bash
# script: libsExample
_AUTHOR_="@fbnmtz"
_CREATED_AT_="2023"
_CURRENT_VERSION_="0.0.1"
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~
# shellcheck disable=SC1090,SC2154
# * SC1090: Can't follow non-constant source. Use a directive to specify location.
# -> cant follow or source usage
# * SC2154: var is referenced but not assigned.
# -> variables will be created by or library system (don't worry)
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~
source ~/bin/xSHELL/init
use args
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~
xarg --id -p,--print --code 'echo print test' --desc 'print some code'
xarg --id -n,--notify --var title+r,text+r --desc 'test notify system'
xarg --id -m,--math --var expression+r --desc 'solve math expression'
xarg --id -V,--volume --var option+r --desc 'volume option (up or down)'
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~
# initilizae values before xrun (if you need to)
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~
# arguments will be checked/validated here (use --xhelp arg for more info)
xrun --xreject-unknow --xrequire-one "$@"
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~
# now put your code below
```
#### Adding custom code
After it, you can create all your code using args defined earlier.
Example:
```bash
# code for -m/--math arg
if [ -n "$expression" ] ; then
echo $(($expression))
fi
# test notification function on lib/system
if [ -n "$title" ]; then
xsys.notify "$title" "$text"
fi
# test volume function on lib/system
if [ -n "$option" ]; then
xsys.vol "--$option"
xsys.notify Volume "$option" # - $(xsys.vol "--status")"
fi
```
#### libsExample output
The code above will generate this output
```
# check help
libsExapmle -h
usage:
libsExapmle [-p] [-n ] [-m ] [-V