container: bash: add plugins support / lib_plugins
- Executes plugins within profile/subprofile context * Hooks into the container's global environment
This commit is contained in:
@@ -58,6 +58,7 @@ function main()
|
|||||||
ledger-ui \e[34;3mStart terminal UI (hledger-ui)\e[0m
|
ledger-ui \e[34;3mStart terminal UI (hledger-ui)\e[0m
|
||||||
ledger-web \e[34;3mStart web-based UI (hledger-web)\e[0m
|
ledger-web \e[34;3mStart web-based UI (hledger-web)\e[0m
|
||||||
meta \e[34;3mSearch local financial metadata\e[0m
|
meta \e[34;3mSearch local financial metadata\e[0m
|
||||||
|
plugins \e[34;3mExecute given plugin available in plugins' path\e[0m
|
||||||
reports \e[34;3mGenerate balance sheet, income statement, etc.\e[0m
|
reports \e[34;3mGenerate balance sheet, income statement, etc.\e[0m
|
||||||
root \e[34;3mRun ROOT.cern instance for docker-finance analysis\e[0m
|
root \e[34;3mRun ROOT.cern instance for docker-finance analysis\e[0m
|
||||||
taxes \e[34;3mGenerate tax reports\e[0m
|
taxes \e[34;3mGenerate tax reports\e[0m
|
||||||
@@ -122,6 +123,9 @@ function main()
|
|||||||
meta)
|
meta)
|
||||||
lib_finance::meta "${@:3}"
|
lib_finance::meta "${@:3}"
|
||||||
;;
|
;;
|
||||||
|
plugins)
|
||||||
|
lib_finance::plugins "${@:3}"
|
||||||
|
;;
|
||||||
reports)
|
reports)
|
||||||
lib_finance::reports "${@:3}"
|
lib_finance::reports "${@:3}"
|
||||||
;;
|
;;
|
||||||
|
|||||||
73
container/src/finance/lib/internal/lib_plugins.bash
Normal file
73
container/src/finance/lib/internal/lib_plugins.bash
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# docker-finance | modern accounting for the power-user
|
||||||
|
#
|
||||||
|
# Copyright (C) 2024 Aaron Fiore (Founder, Evergreen Crypto LLC)
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation either version 3 of the License or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#
|
||||||
|
# "Libraries"
|
||||||
|
#
|
||||||
|
|
||||||
|
[ -z "$DOCKER_FINANCE_CONTAINER_REPO" ] && exit 1
|
||||||
|
source "${DOCKER_FINANCE_CONTAINER_REPO}/src/finance/lib/internal/lib_utils.bash" || exit 1
|
||||||
|
|
||||||
|
#
|
||||||
|
# Facade
|
||||||
|
#
|
||||||
|
|
||||||
|
function lib_plugins::plugins()
|
||||||
|
{
|
||||||
|
# NOTE: no args to parse, pass directly to plugin
|
||||||
|
lib_plugins::__plugins "$@"
|
||||||
|
lib_utils::catch $?
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Implementation
|
||||||
|
#
|
||||||
|
|
||||||
|
function lib_plugins::__plugins()
|
||||||
|
{
|
||||||
|
[ -z "$global_usage" ] && lib_utils::die_fatal
|
||||||
|
|
||||||
|
[ -z "$DOCKER_FINANCE_CONTAINER_FLOW" ] && lib_utils::die_fatal
|
||||||
|
local -r _path="${DOCKER_FINANCE_CONTAINER_FLOW}/plugins"
|
||||||
|
|
||||||
|
local -r _usage="
|
||||||
|
\e[32mDescription:\e[0m
|
||||||
|
|
||||||
|
Execute a plugin within the flow plugins path
|
||||||
|
|
||||||
|
\e[32mUsage:\e[0m
|
||||||
|
|
||||||
|
$ $global_usage <plugin> [args]
|
||||||
|
|
||||||
|
\e[32mExamples:\e[0m
|
||||||
|
|
||||||
|
\e[37;2m# Execute a custom plugin in ${_path}\e[0m
|
||||||
|
$ $global_usage example.bash \"hello\"
|
||||||
|
"
|
||||||
|
|
||||||
|
if [ "$#" -eq 0 ]; then
|
||||||
|
lib_utils::die_usage "$_usage"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec ${_path}/$*
|
||||||
|
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
|
# vim: sw=2 sts=2 si ai et
|
||||||
@@ -87,6 +87,7 @@ function lib_finance::finance()
|
|||||||
source "${DOCKER_FINANCE_CONTAINER_REPO}/src/finance/lib/internal/lib_fetch.bash" || exit 1
|
source "${DOCKER_FINANCE_CONTAINER_REPO}/src/finance/lib/internal/lib_fetch.bash" || exit 1
|
||||||
source "${DOCKER_FINANCE_CONTAINER_REPO}/src/finance/lib/internal/lib_ledger.bash" || exit 1
|
source "${DOCKER_FINANCE_CONTAINER_REPO}/src/finance/lib/internal/lib_ledger.bash" || exit 1
|
||||||
source "${DOCKER_FINANCE_CONTAINER_REPO}/src/finance/lib/internal/lib_meta.bash" || exit 1
|
source "${DOCKER_FINANCE_CONTAINER_REPO}/src/finance/lib/internal/lib_meta.bash" || exit 1
|
||||||
|
source "${DOCKER_FINANCE_CONTAINER_REPO}/src/finance/lib/internal/lib_plugins.bash" || exit 1
|
||||||
source "${DOCKER_FINANCE_CONTAINER_REPO}/src/finance/lib/internal/lib_reports.bash" || exit 1
|
source "${DOCKER_FINANCE_CONTAINER_REPO}/src/finance/lib/internal/lib_reports.bash" || exit 1
|
||||||
source "${DOCKER_FINANCE_CONTAINER_REPO}/src/finance/lib/internal/lib_taxes.bash" || exit 1
|
source "${DOCKER_FINANCE_CONTAINER_REPO}/src/finance/lib/internal/lib_taxes.bash" || exit 1
|
||||||
}
|
}
|
||||||
@@ -199,6 +200,12 @@ function lib_finance::ledger-web()
|
|||||||
lib_utils::catch $?
|
lib_utils::catch $?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function lib_finance::plugins()
|
||||||
|
{
|
||||||
|
lib_plugins::plugins "$@"
|
||||||
|
lib_utils::catch $?
|
||||||
|
}
|
||||||
|
|
||||||
function lib_finance::reports()
|
function lib_finance::reports()
|
||||||
{
|
{
|
||||||
lib_reports::reports "$@"
|
lib_reports::reports "$@"
|
||||||
|
|||||||
Reference in New Issue
Block a user