container: plugins: refactor example plugin
- Refactor instance - Refactor main()
This commit is contained in:
@@ -38,9 +38,12 @@
|
|||||||
[ -z "$DOCKER_FINANCE_CONTAINER_REPO" ] && exit 1
|
[ -z "$DOCKER_FINANCE_CONTAINER_REPO" ] && exit 1
|
||||||
source "${DOCKER_FINANCE_CONTAINER_REPO}/src/finance/lib/lib_finance.bash"
|
source "${DOCKER_FINANCE_CONTAINER_REPO}/src/finance/lib/lib_finance.bash"
|
||||||
|
|
||||||
|
[[ -z "$global_parent_profile" || -z "$global_arg_delim_1" || -z "$global_child_profile" ]] && lib_utils::die_fatal
|
||||||
|
instance="${global_parent_profile}${global_arg_delim_1}${global_child_profile}"
|
||||||
|
|
||||||
# Initialize "constructor"
|
# Initialize "constructor"
|
||||||
[[ -z "$global_parent_profile" || -z "$global_arg_delim_1" || -z "$global_child_profile" ]] && exit 1
|
# NOTE: "constructor" only needed if calling library directly
|
||||||
lib_finance::finance "${global_parent_profile}${global_arg_delim_1}${global_child_profile}"
|
lib_finance::finance "$instance" || lib_utils::die_fatal
|
||||||
|
|
||||||
#
|
#
|
||||||
# Implementation
|
# Implementation
|
||||||
@@ -48,14 +51,14 @@ lib_finance::finance "${global_parent_profile}${global_arg_delim_1}${global_chil
|
|||||||
|
|
||||||
function main()
|
function main()
|
||||||
{
|
{
|
||||||
echo -e "
|
local -r _example="
|
||||||
This container's environment:
|
This container's environment:
|
||||||
|
|
||||||
$(printenv | grep ^DOCKER_FINANCE | sort)
|
$(printenv | grep ^DOCKER_FINANCE | sort)
|
||||||
|
|
||||||
This plugin's caller profile:
|
This plugin's caller profile:
|
||||||
|
|
||||||
${global_parent_profile}${global_arg_delim_1}${global_child_profile}
|
$instance
|
||||||
|
|
||||||
This plugin's path is:
|
This plugin's path is:
|
||||||
|
|
||||||
@@ -66,10 +69,11 @@ This plugin's arguments:
|
|||||||
'${*}'
|
'${*}'
|
||||||
|
|
||||||
Showing total current BTC balance:
|
Showing total current BTC balance:
|
||||||
|
|
||||||
|
$(lib_finance::ledger bal assets liabilities cur:BTC | tail -n1)
|
||||||
|
|
||||||
"
|
"
|
||||||
echo -n " "
|
lib_utils::print_custom "$_example"
|
||||||
lib_finance::ledger bal assets liabilities cur:BTC | tail -n1
|
|
||||||
echo
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|||||||
Reference in New Issue
Block a user