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: 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: Account:
@@ -160,7 +160,7 @@ function lib_edit::__parse_args()
read -ra _read <<<"$_arg_type" read -ra _read <<<"$_arg_type"
for _type in "${_read[@]}"; do 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" lib_utils::die_usage "$_usage"
fi fi
if [[ ! -z "$_arg_account" ]]; then if [[ ! -z "$_arg_account" ]]; then
@@ -237,7 +237,7 @@ function lib_edit::__edit()
$EDITOR "$_path" || lib_utils::die_fatal $EDITOR "$_path" || lib_utils::die_fatal
;; ;;
iadd | manual) add | iadd | manual)
[ -z "$global_child_profile" ] && lib_utils::die_fatal [ -z "$global_child_profile" ] && lib_utils::die_fatal
[ -z "$global_child_profile_flow" ] && 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" _path+="/post-import.journal"
[ ! -f "$_path" ] && touch "$_path" [ ! -f "$_path" ] && touch "$_path"
if [[ "$_type" == "iadd" ]]; then case "$_type" in
lib_utils::deps_check "hledger-iadd" add)
hledger-iadd -f "$_path" || lib_utils::die_fatal hledger -f "$_path" add || lib_utils::die_fatal
fi ;;
iadd)
if [[ "$_type" == "manual" ]]; then lib_utils::deps_check "hledger-iadd"
$EDITOR "$_path" || lib_utils::die_fatal hledger-iadd -f "$_path" || lib_utils::die_fatal
fi ;;
manual)
$EDITOR "$_path" || lib_utils::die_fatal
;;
*)
lib_utils::die_fatal
;;
esac
;; ;;
meta) meta)
[ -z "$global_conf_meta" ] && lib_utils::die_fatal [ -z "$global_conf_meta" ] && lib_utils::die_fatal