hledger-flow: lib_preprocess: allow testing of single / multiple columns
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# docker-finance | modern accounting for the power-user
|
# docker-finance | modern accounting for the power-user
|
||||||
#
|
#
|
||||||
# Copyright (C) 2021-2024 Aaron Fiore (Founder, Evergreen Crypto LLC)
|
# Copyright (C) 2021-2025 Aaron Fiore (Founder, Evergreen Crypto LLC)
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -60,13 +60,13 @@ echo -e " \e[32m├─\e[34m\e[1;3m ${global_account}/${global_subaccount}\e[
|
|||||||
echo -e " \e[32m│ └─\e[34;3m ${global_year}\e[0m"
|
echo -e " \e[32m│ └─\e[34;3m ${global_year}\e[0m"
|
||||||
echo -e " \e[32m│ └─\e[37;2m ${global_in_filename}\e[0m"
|
echo -e " \e[32m│ └─\e[37;2m ${global_in_filename}\e[0m"
|
||||||
|
|
||||||
# Search for column in given CSV header
|
# Test if column(s) exist in given CSV header
|
||||||
function lib_preprocess::test_header()
|
function lib_preprocess::test_header()
|
||||||
{
|
{
|
||||||
local _column="$1"
|
local _column="$1"
|
||||||
local _header
|
local _header
|
||||||
_header="$(lib_preprocess::__sanitize_header $2)"
|
_header="$(lib_preprocess::__sanitize_header $2)"
|
||||||
[[ "$_header" =~ (^${_column},|,${_column},|,${_column}$) ]] && return 0 || return 2
|
[[ "$_header" =~ (^${_column}$|^${_column},|,${_column},|,${_column}$) ]] && return 0 || return 2
|
||||||
}
|
}
|
||||||
|
|
||||||
# Assert header in given CSV header
|
# Assert header in given CSV header
|
||||||
|
|||||||
Reference in New Issue
Block a user