container: lib_edit: add hledger 'add' command

This commit is contained in:
2024-10-01 17:29:51 -07:00
parent 75729adbbe
commit 249ebe03d6

View File

@@ -59,7 +59,7 @@ function lib_edit::__parse_args()
Configuration type:
type${global_arg_delim_2}<fetch|hledger|iadd|manual|meta|{shell|subscript}|rules|preprocess>
type${global_arg_delim_2}<fetch|hledger|{add|iadd|manual}|meta|{shell|subscript}|rules|preprocess>
Account:
@@ -160,7 +160,7 @@ function lib_edit::__parse_args()
read -ra _read <<<"$_arg_type"
for _type in "${_read[@]}"; do
if [[ ! "$_type" =~ ^fetch$|^hledger$|^iadd$|^manual$|^meta$|^preprocess$|^rules$|^shell$|^subscript$ ]]; then
if [[ ! "$_type" =~ ^fetch$|^hledger$|^add$|^iadd$|^manual$|^meta$|^preprocess$|^rules$|^shell$|^subscript$ ]]; then
lib_utils::die_usage "$_usage"
fi
if [[ ! -z "$_arg_account" ]]; then
@@ -237,7 +237,7 @@ function lib_edit::__edit()
$EDITOR "$_path" || lib_utils::die_fatal
;;
iadd | manual)
add | iadd | manual)
[ -z "$global_child_profile" ] && lib_utils::die_fatal
[ -z "$global_child_profile_flow" ] && lib_utils::die_fatal
@@ -247,14 +247,21 @@ function lib_edit::__edit()
_path+="/post-import.journal"
[ ! -f "$_path" ] && touch "$_path"
if [[ "$_type" == "iadd" ]]; then
lib_utils::deps_check "hledger-iadd"
hledger-iadd -f "$_path" || lib_utils::die_fatal
fi
if [[ "$_type" == "manual" ]]; then
$EDITOR "$_path" || lib_utils::die_fatal
fi
case "$_type" in
add)
hledger -f "$_path" add || lib_utils::die_fatal
;;
iadd)
lib_utils::deps_check "hledger-iadd"
hledger-iadd -f "$_path" || lib_utils::die_fatal
;;
manual)
$EDITOR "$_path" || lib_utils::die_fatal
;;
*)
lib_utils::die_fatal
;;
esac
;;
meta)
[ -z "$global_conf_meta" ] && lib_utils::die_fatal