-
Notifications
You must be signed in to change notification settings - Fork 0
/
libsExapmle
executable file
·73 lines (63 loc) · 2.76 KB
/
libsExapmle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env bash
#
# ############################################################################
# Project: bin (none)
# File...: xSHELL/libsExapmle
# Created: Thursday, 2023/01/05 - 15:09:19
# Author.: @fbnmtz, (fabiano.matoz@gmail.com)
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Last Modified: Thursday, 2023/01/19 - 16:38:34
# Modified By..: @fbnmtz, (fabiano.matoz@gmail.com)
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Version: 0.0.6.81
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Description:
# >
# ############################################################################
# HISTORY:
#
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~
# shellcheck disable=SC1090,SC2154
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~
# import lib system to your script
source ~/bin/xSHELL/init
# load basic lib 'args'
use args
# you can list/validade all binaries/tools needed by your script easily using 'requirements' function
xrequirements echo
# now, you can easily define args and usage info with 'xarg' function
# params supported:
# * --id <shortflat,longflag>
# this param require two params
# 1. --var or --code
# 2. --desc
# * --var <var1:varvalue,var2+r,var3+o>
# * --desc <description>
# We have another param made to be used alone
# * --section <group name>
# this param will group args defined after it
# example: how to set args/actions
xarg --section "Custom 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)"
# after define args, pass all script params (var $@) to 'xrun' function
# xrun optional params:
# * --xreject-unknow : throw error when receive an parameter not defined with 'xarg'
# * --xrequire-one...: throw error if no param given
# * --xversionrc.....: show full version with release candidate
xrun --xreject-unknow --xrequire-one --xversionrc "$@"
# 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