diff --git a/client/src/docker/lib/internal/lib_gen.bash b/client/src/docker/lib/internal/lib_gen.bash
index fb1892d..cbb07c5 100644
--- a/client/src/docker/lib/internal/lib_gen.bash
+++ b/client/src/docker/lib/internal/lib_gen.bash
@@ -436,15 +436,93 @@ function lib_gen::__gen_container()
mkdir -p "$DOCKER_FINANCE_CLIENT_FLOW" || lib_utils::die_fatal
fi
- #
- # Generate profile/subprofile
- #
-
+ lib_gen::__gen_plugins
lib_gen::__gen_profile
}
+#
+# Generate flow: plugins
+#
+# - Provides a place to drop-in any custom plugin
+# - Provides a default example plugin
+#
+
+function lib_gen::__gen_plugins()
+{
+ lib_utils::print_debug "Generating plugins"
+
+ local -r _plugins="${DOCKER_FINANCE_CLIENT_FLOW}/plugins"
+ if [ ! -d "$_plugins" ]; then
+ mkdir -p "$_plugins" || lib_utils::die_fatal
+ fi
+
+ local -r _example="${_plugins}/example.bash"
+
+ if [ -f "$_example" ]; then
+ lib_utils::print_debug "Example plugin found, overwriting: '${_example}'"
+ fi
+
+ echo "#!/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 .
+
+#
+# Plugins
+#
+# The plugins path (this directory) is where you can place any executable.
+#
+# Any plugin found in this directory will be made available via the \`plugins\` command.
+# As such, your plugin will have access to all global variables provided by finance.bash
+#
+# The following is an example of how to create your own plugin:
+#
+
+echo -e \"
+This container's environment:
+
+\$(printenv | grep ^DOCKER_FINANCE)
+
+This plugin's caller profile:
+
+ \${global_parent_profile}\${global_arg_delim_1}\${global_child_profile}
+
+This plugin's path is:
+
+ \$0
+
+This plugin's arguments:
+
+ '\${@}'
+\"
+
+# vim: sw=2 sts=2 si ai et" >"$_example"
+
+ chmod +x "$_example" || lib_utils::die_fatal
+}
+
+#
+# Generate flow: profile/subprofile
+#
+
function lib_gen::__gen_profile()
{
+ lib_utils::print_debug "Generating profiles"
+
local -r _profiles="${DOCKER_FINANCE_CLIENT_FLOW}/profiles"
if [ ! -d "$_profiles" ]; then
mkdir -p "$_profiles" || lib_utils::die_fatal
diff --git a/container/src/finance/completion.bash b/container/src/finance/completion.bash
index 0678b31..34d1106 100644
--- a/container/src/finance/completion.bash
+++ b/container/src/finance/completion.bash
@@ -28,7 +28,7 @@ function docker-finance::completion()
mapfile -t _profiles < <(pushd "${DOCKER_FINANCE_CONTAINER_FLOW}"/profiles &>/dev/null && ls -d */*)
declare -r _profiles
- local -r _commands=("all" "edit" "fetch" "import" "ledger" "ledger-ui" "ledger-web" "meta" "reports" "root" "taxes")
+ local -r _commands=("all" "edit" "fetch" "import" "ledger" "ledger-ui" "ledger-web" "meta" "plugins" "reports" "root" "taxes")
local _reply
@@ -76,6 +76,12 @@ function docker-finance::completion()
# NOTE: args are dependent upon metadata contents
mapfile -t _reply < <(compgen -W "help" -- "$_cur")
;;
+ plugins)
+ local _plugins
+ mapfile -t _plugins < <(find "${DOCKER_FINANCE_CONTAINER_FLOW}"/plugins -type f -executable -printf '%P\n' 2>/dev/null)
+ declare -r _plugins
+ mapfile -t _reply < <(compgen -W "${_plugins[*]}" -- "$_cur")
+ ;;
reports)
mapfile -t _reply < <(compgen -W "help all${global_arg_delim_2} type${global_arg_delim_2} interval${global_arg_delim_2} year${global_arg_delim_2}" -- "$_cur")
;;
diff --git a/container/src/finance/finance.bash b/container/src/finance/finance.bash
index e889c1e..324a413 100755
--- a/container/src/finance/finance.bash
+++ b/container/src/finance/finance.bash
@@ -58,6 +58,7 @@ function main()
ledger-ui \e[34;3mStart terminal UI (hledger-ui)\e[0m
ledger-web \e[34;3mStart web-based UI (hledger-web)\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
root \e[34;3mRun ROOT.cern instance for docker-finance analysis\e[0m
taxes \e[34;3mGenerate tax reports\e[0m
@@ -122,6 +123,9 @@ function main()
meta)
lib_finance::meta "${@:3}"
;;
+ plugins)
+ lib_finance::plugins "${@:3}"
+ ;;
reports)
lib_finance::reports "${@:3}"
;;
diff --git a/container/src/finance/lib/internal/lib_plugins.bash b/container/src/finance/lib/internal/lib_plugins.bash
new file mode 100644
index 0000000..9fe3c52
--- /dev/null
+++ b/container/src/finance/lib/internal/lib_plugins.bash
@@ -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 .
+
+#
+# "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 [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
diff --git a/container/src/finance/lib/lib_finance.bash b/container/src/finance/lib/lib_finance.bash
index 5f80c71..3ffb83a 100644
--- a/container/src/finance/lib/lib_finance.bash
+++ b/container/src/finance/lib/lib_finance.bash
@@ -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_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_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_taxes.bash" || exit 1
}
@@ -199,6 +200,12 @@ function lib_finance::ledger-web()
lib_utils::catch $?
}
+function lib_finance::plugins()
+{
+ lib_plugins::plugins "$@"
+ lib_utils::catch $?
+}
+
function lib_finance::reports()
{
lib_reports::reports "$@"