forked from EvergreenCrypto/docker-finance
client/container: rename 'subprofile' script to 'subscript'
- Provides clarity, avoids confusion (subprofile.bash -> subscript.bash) - Changes filename in superscript source * End-user must update with client command `edit type=superscript` - Changes filename in flow subprofile's docker-finance.d * Pre-existing subprofiles must manually rename their subscript file
This commit is contained in:
@@ -20,7 +20,7 @@
|
|||||||
# docker-finance @DOCKER_FINANCE_VERSION@
|
# docker-finance @DOCKER_FINANCE_VERSION@
|
||||||
|
|
||||||
#
|
#
|
||||||
# Subprofile script
|
# Subscript (subprofile script) called by superscript
|
||||||
#
|
#
|
||||||
|
|
||||||
[ -z "$DOCKER_FINANCE_CONTAINER_CMD" ] && echo "DOCKER_FINANCE_CONTAINER_CMD not set, check installation" >&2
|
[ -z "$DOCKER_FINANCE_CONTAINER_CMD" ] && echo "DOCKER_FINANCE_CONTAINER_CMD not set, check installation" >&2
|
||||||
@@ -74,7 +74,7 @@ function lib_gen::__parse_args()
|
|||||||
|
|
||||||
Configuration type:
|
Configuration type:
|
||||||
|
|
||||||
config${global_arg_delim_2}<fetch | hledger | meta | subprofile>
|
config${global_arg_delim_2}<fetch | hledger | meta | subscript>
|
||||||
|
|
||||||
Accounts:
|
Accounts:
|
||||||
|
|
||||||
@@ -128,13 +128,13 @@ function lib_gen::__parse_args()
|
|||||||
$ $global_usage type${global_arg_delim_2}env${global_arg_delim_3}build${global_arg_delim_3}superscript${global_arg_delim_3}flow profile${global_arg_delim_2}parent${global_arg_delim_1}child confirm${global_arg_delim_2}false dev${global_arg_delim_2}true
|
$ $global_usage type${global_arg_delim_2}env${global_arg_delim_3}build${global_arg_delim_3}superscript${global_arg_delim_3}flow profile${global_arg_delim_2}parent${global_arg_delim_1}child confirm${global_arg_delim_2}false dev${global_arg_delim_2}true
|
||||||
|
|
||||||
\e[37;2m# Generate only the given configurations for 'parent/child'\e[0m
|
\e[37;2m# Generate only the given configurations for 'parent/child'\e[0m
|
||||||
$ $global_usage type${global_arg_delim_2}flow profile${global_arg_delim_2}parent${global_arg_delim_1}child config${global_arg_delim_2}fetch${global_arg_delim_3}hledger${global_arg_delim_3}meta${global_arg_delim_3}subprofile
|
$ $global_usage type${global_arg_delim_2}flow profile${global_arg_delim_2}parent${global_arg_delim_1}child config${global_arg_delim_2}fetch${global_arg_delim_3}hledger${global_arg_delim_3}meta${global_arg_delim_3}subscript
|
||||||
|
|
||||||
\e[37;2m# Generate only the given accounts for 'parent/child'\e[0m
|
\e[37;2m# Generate only the given accounts for 'parent/child'\e[0m
|
||||||
$ $global_usage type${global_arg_delim_2}flow profile${global_arg_delim_2}parent${global_arg_delim_1}child account${global_arg_delim_2}capital-one${global_arg_delim_3}chase${global_arg_delim_3}coinbase
|
$ $global_usage type${global_arg_delim_2}flow profile${global_arg_delim_2}parent${global_arg_delim_1}child account${global_arg_delim_2}capital-one${global_arg_delim_3}chase${global_arg_delim_3}coinbase
|
||||||
|
|
||||||
\e[37;2m# Generate the given configs and accounts for given 'parent/child'\e[0m
|
\e[37;2m# Generate the given configs and accounts for given 'parent/child'\e[0m
|
||||||
$ $global_usage type${global_arg_delim_2}flow profile${global_arg_delim_2}parent${global_arg_delim_1}child config${global_arg_delim_2}meta${global_arg_delim_3}subprofile account${global_arg_delim_2}ethereum-based${global_arg_delim_3}metamask
|
$ $global_usage type${global_arg_delim_2}flow profile${global_arg_delim_2}parent${global_arg_delim_1}child config${global_arg_delim_2}meta${global_arg_delim_3}subscript account${global_arg_delim_2}ethereum-based${global_arg_delim_3}metamask
|
||||||
|
|
||||||
\e[32mNotes:\e[0m
|
\e[32mNotes:\e[0m
|
||||||
|
|
||||||
@@ -307,7 +307,7 @@ function lib_gen::__parse_args()
|
|||||||
fi
|
fi
|
||||||
read -ra _read <<<"$_arg_config"
|
read -ra _read <<<"$_arg_config"
|
||||||
for _arg in "${_read[@]}"; do
|
for _arg in "${_read[@]}"; do
|
||||||
if [[ ! "$_arg" =~ ^fetch$|^hledger$|^meta$|^subprofile$ ]]; then
|
if [[ ! "$_arg" =~ ^fetch$|^hledger$|^meta$|^subscript$ ]]; then
|
||||||
lib_utils::die_usage "$_usage"
|
lib_utils::die_usage "$_usage"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@@ -734,14 +734,14 @@ function lib_gen::__gen_subprofile_flow()
|
|||||||
{
|
{
|
||||||
[[ -z "$_gen_path" || -z "$_gen_conf_path" ]] && lib_utils::die_fatal
|
[[ -z "$_gen_path" || -z "$_gen_conf_path" ]] && lib_utils::die_fatal
|
||||||
|
|
||||||
if lib_gen::__gen_subprofile_flow_args_config "subprofile"; then
|
if lib_gen::__gen_subprofile_flow_args_config "subscript"; then
|
||||||
lib_utils::print_custom " \e[32m│ │ │\e[0m\n"
|
lib_utils::print_custom " \e[32m│ │ │\e[0m\n"
|
||||||
lib_utils::print_custom " \e[32m│ │ ├─\e[34;1m Generate (or update) subprofile's shell script? [Y/n] \e[0m"
|
lib_utils::print_custom " \e[32m│ │ ├─\e[34;1m Generate (or update) subprofile's subscript file? [Y/n] \e[0m"
|
||||||
[ -z "$global_arg_confirm" ] && lib_utils::print_custom "\n" || read -p "" _read
|
[ -z "$global_arg_confirm" ] && lib_utils::print_custom "\n" || read -p "" _read
|
||||||
_confirm="${_read:-y}"
|
_confirm="${_read:-y}"
|
||||||
if [[ "$_confirm" == [yY] || -z "$global_arg_confirm" ]]; then
|
if [[ "$_confirm" == [yY] || -z "$global_arg_confirm" ]]; then
|
||||||
# Subprofile's shell script
|
# Subprofile's shell script
|
||||||
lib_gen::__gen_subprofile_flow_shell
|
lib_gen::__gen_subprofile_flow_subscript
|
||||||
# Append subprofile source to superscript
|
# Append subprofile source to superscript
|
||||||
lib_gen::__gen_subprofile_flow_superscript
|
lib_gen::__gen_subprofile_flow_superscript
|
||||||
fi
|
fi
|
||||||
@@ -815,31 +815,31 @@ function lib_gen::__gen_subprofile_flow_args_account()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Subprofile: flow: generate subprofile script
|
# Subprofile: flow: generate subprofile subscript
|
||||||
#
|
#
|
||||||
|
|
||||||
function lib_gen::__gen_subprofile_flow_shell()
|
function lib_gen::__gen_subprofile_flow_subscript()
|
||||||
{
|
{
|
||||||
[[ -z "$_gen_path" || -z "$_gen_conf_path" ]] && lib_utils::die_fatal
|
[[ -z "$_gen_path" || -z "$_gen_conf_path" ]] && lib_utils::die_fatal
|
||||||
|
|
||||||
local _dir="${_gen_conf_path}/shell"
|
local _dir="${_gen_conf_path}/shell"
|
||||||
[ ! -d "$_dir" ] && mkdir -p "$_dir"
|
[ ! -d "$_dir" ] && mkdir -p "$_dir"
|
||||||
|
|
||||||
local _file="${_dir}/subprofile.bash"
|
local _file="${_dir}/subscript.bash"
|
||||||
if [ -f "$_file" ]; then
|
if [ -f "$_file" ]; then
|
||||||
lib_utils::print_custom " \e[32m│ │ │ └─\e[34m Subprofile script found, backup then generate new one? [Y/n] \e[0m"
|
lib_utils::print_custom " \e[32m│ │ │ └─\e[34m Subprofile subscript found, backup then generate new one? [Y/n] \e[0m"
|
||||||
[ -z "$global_arg_confirm" ] && lib_utils::print_custom "\n" || read -p "" _read
|
[ -z "$global_arg_confirm" ] && lib_utils::print_custom "\n" || read -p "" _read
|
||||||
_confirm="${_read:-y}"
|
_confirm="${_read:-y}"
|
||||||
|
|
||||||
if [[ "$_confirm" == [yY] || -z "$global_arg_confirm" ]]; then
|
if [[ "$_confirm" == [yY] || -z "$global_arg_confirm" ]]; then
|
||||||
cp -a "$_file" "${_file}_${global_suffix}" || lib_utils::die_fatal
|
cp -a "$_file" "${_file}_${global_suffix}" || lib_utils::die_fatal
|
||||||
|
|
||||||
lib_gen::__gen_subprofile_flow_shell_write
|
lib_gen::__gen_subprofile_flow_subscript_write
|
||||||
local _print_custom=" \e[32m│ │ │ └─\e[34m Edit (new) subprofile script now? [Y/n] \e[0m"
|
local _print_custom=" \e[32m│ │ │ └─\e[34m Edit (new) subprofile subscript now? [Y/n] \e[0m"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
lib_gen::__gen_subprofile_flow_shell_write
|
lib_gen::__gen_subprofile_flow_subscript_write
|
||||||
local _print_custom=" \e[32m│ │ │ └─\e[34m Edit (new) subprofile script now? [Y/n] \e[0m"
|
local _print_custom=" \e[32m│ │ │ └─\e[34m Edit (new) subprofile subscript now? [Y/n] \e[0m"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
lib_utils::print_custom "$_print_custom"
|
lib_utils::print_custom "$_print_custom"
|
||||||
@@ -848,7 +848,7 @@ function lib_gen::__gen_subprofile_flow_shell()
|
|||||||
[[ "$_confirm" == [yY] || -z "$global_arg_confirm" ]] && $EDITOR "$_file"
|
[[ "$_confirm" == [yY] || -z "$global_arg_confirm" ]] && $EDITOR "$_file"
|
||||||
}
|
}
|
||||||
|
|
||||||
function lib_gen::__gen_subprofile_flow_shell_write()
|
function lib_gen::__gen_subprofile_flow_subscript_write()
|
||||||
{
|
{
|
||||||
[[ -z "$DOCKER_FINANCE_CONTAINER_REPO" || -z "$DOCKER_FINANCE_CONTAINER_CMD" ]] && lib_utils::die_fatal
|
[[ -z "$DOCKER_FINANCE_CONTAINER_REPO" || -z "$DOCKER_FINANCE_CONTAINER_CMD" ]] && lib_utils::die_fatal
|
||||||
|
|
||||||
@@ -863,7 +863,7 @@ function lib_gen::__gen_subprofile_flow_shell_write()
|
|||||||
-e "s:@DOCKER_FINANCE_VERSION@:${global_client_version}:g" \
|
-e "s:@DOCKER_FINANCE_VERSION@:${global_client_version}:g" \
|
||||||
-e "s:@DOCKER_FINANCE_PROFILE@:${_profile}:g" \
|
-e "s:@DOCKER_FINANCE_PROFILE@:${_profile}:g" \
|
||||||
-e "s:@DOCKER_FINANCE_SUBPROFILE@:${_subprofile}:g" \
|
-e "s:@DOCKER_FINANCE_SUBPROFILE@:${_subprofile}:g" \
|
||||||
"${global_repo_conf_dir}/container/shell/subprofile.bash.in" >"$_file"
|
"${global_repo_conf_dir}/container/shell/subscript.bash.in" >"$_file"
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -878,7 +878,7 @@ function lib_gen::__gen_subprofile_flow_superscript()
|
|||||||
[ ! -f "$global_shell_file" ] && lib_utils::die_fatal "Superscript does not exist!"
|
[ ! -f "$global_shell_file" ] && lib_utils::die_fatal "Superscript does not exist!"
|
||||||
|
|
||||||
# Append subprofile source to superscript
|
# Append subprofile source to superscript
|
||||||
local -r _source="source \"\${DOCKER_FINANCE_CONTAINER_FLOW}/profiles/${_profile}/${_subprofile}/docker-finance.d/shell/subprofile.bash\""
|
local -r _source="source \"\${DOCKER_FINANCE_CONTAINER_FLOW}/profiles/${_profile}/${_subprofile}/docker-finance.d/shell/subscript.bash\""
|
||||||
lib_utils::print_custom " \e[32m│ │ │ └─\e[34m Appending subprofile to superscript\e[0m\n"
|
lib_utils::print_custom " \e[32m│ │ │ └─\e[34m Appending subprofile to superscript\e[0m\n"
|
||||||
|
|
||||||
# If source subprofile does not exist, append
|
# If source subprofile does not exist, append
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ function lib_finance::finance()
|
|||||||
declare -grx global_conf_fetch="${global_child_profile_flow}/docker-finance.d/fetch/fetch.yaml"
|
declare -grx global_conf_fetch="${global_child_profile_flow}/docker-finance.d/fetch/fetch.yaml"
|
||||||
declare -grx global_conf_hledger="${global_child_profile_flow}/docker-finance.d/hledger/hledger.conf"
|
declare -grx global_conf_hledger="${global_child_profile_flow}/docker-finance.d/hledger/hledger.conf"
|
||||||
declare -grx global_conf_meta="${global_child_profile_flow}/docker-finance.d/meta/meta.csv"
|
declare -grx global_conf_meta="${global_child_profile_flow}/docker-finance.d/meta/meta.csv"
|
||||||
declare -grx global_conf_shell="${global_child_profile_flow}/docker-finance.d/shell/subprofile.bash"
|
declare -grx global_conf_shell="${global_child_profile_flow}/docker-finance.d/shell/subscript.bash"
|
||||||
|
|
||||||
# Implementation "libraries" (requires previously set globals)
|
# Implementation "libraries" (requires previously set globals)
|
||||||
source "${DOCKER_FINANCE_CONTAINER_REPO}/src/finance/lib/internal/lib_edit.bash" || exit 1
|
source "${DOCKER_FINANCE_CONTAINER_REPO}/src/finance/lib/internal/lib_edit.bash" || exit 1
|
||||||
|
|||||||
Reference in New Issue
Block a user