container: migrate from xsv to xan
`xsv` is no longer maintained and the author recommends `xan` instead. Fortunately, `xan` is very suitable for our use-case; is very efficient, and produces no differences in our expected output.
This commit is contained in:
@@ -65,7 +65,7 @@ function lib_meta::__parse_args()
|
||||
|
||||
\e[32mAvailable columns:\e[0m
|
||||
|
||||
$(echo $global_meta_header | xsv headers -)
|
||||
$(echo $global_meta_header | xan headers -)
|
||||
|
||||
\e[32mExamples:\e[0m
|
||||
|
||||
@@ -123,7 +123,7 @@ function lib_meta::__meta()
|
||||
# Nth iteration (select column and pattern)
|
||||
local _tmp_file
|
||||
_tmp_file="$(mktemp -p $_tmp_dir ${_arg}_XXX)"
|
||||
xsv search -i -s \
|
||||
xan search -i -s \
|
||||
"${_arg%${global_arg_delim_2}*}" "${_arg#*${global_arg_delim_2}}" \
|
||||
"$_base_file" >"$_tmp_file"
|
||||
|
||||
|
||||
@@ -430,7 +430,7 @@ function lib_taxes::__taxes_print()
|
||||
|
||||
if [[ "$_tag" != "MATCH" && "$_tag" != "PARTIAL_TRADE" ]]; then
|
||||
"${_hledger[@]}" \
|
||||
| xsv select '"posting-comment"' \
|
||||
| xan select '"posting-comment"' \
|
||||
| tail -n +2 \
|
||||
| sed -e 's:"::g' -e '/^$/d' \
|
||||
| gawk -v tag="$_tag" -v is_trades="$_is_trades" \
|
||||
@@ -607,7 +607,7 @@ function lib_taxes::__taxes_print()
|
||||
|
||||
if [[ "$_tag" == "MATCH" ]]; then
|
||||
"${_hledger[@]}" \
|
||||
| xsv select '"posting-comment"' \
|
||||
| xan select '"posting-comment"' \
|
||||
| tail -n +2 \
|
||||
| sed -e 's:"::g' -e '/^$/d' \
|
||||
| sort -u \
|
||||
@@ -856,7 +856,7 @@ function lib_taxes::__taxes_print()
|
||||
|
||||
if [[ "$_tag" == "PARTIAL_TRADE" ]]; then
|
||||
"${_hledger[@]}" \
|
||||
| xsv select '"posting-comment"' \
|
||||
| xan select '"posting-comment"' \
|
||||
| tail -n +2 \
|
||||
| sed -e 's:"::g' -e '/^$/d' \
|
||||
| sort -u \
|
||||
@@ -1002,7 +1002,7 @@ function lib_taxes::__taxes_write()
|
||||
if [ -z "$global_arg_year" ]; then
|
||||
lib_utils::print_normal "Capturing the year of the oldest tagged record ..."
|
||||
|
||||
local -r _oldest_year="$("${_base_hledger[@]}" | head -n2 | xsv select \"date\" | tail -n1 | cut -d'-' -f1)"
|
||||
local -r _oldest_year="$("${_base_hledger[@]}" | head -n2 | xan select \"date\" | tail -n1 | cut -d'-' -f1)"
|
||||
[ -z "$_oldest_year" ] && lib_utils::die_fatal "No records available to write"
|
||||
|
||||
elif [[ "$global_arg_year" -gt "$_current_year" ]]; then
|
||||
@@ -1247,7 +1247,7 @@ function lib_taxes::__reports_patch_verify()
|
||||
[ ! -f "$_file" ] && lib_utils::die_fatal "File not found: '${_file}'"
|
||||
|
||||
if [ -s "$_file" ]; then
|
||||
xsv select "Action" "$_file" \
|
||||
xan select "Action" "$_file" \
|
||||
| sort -u \
|
||||
| tail -n +2 \
|
||||
| while read _line; do
|
||||
@@ -1295,7 +1295,7 @@ function lib_taxes::__reports_obfs_gen()
|
||||
|
||||
# Generate obfs/raw keymap
|
||||
local _raw_column
|
||||
_raw_column="$(xsv select $_column $_in_file | tail -n +2 | sort -u)"
|
||||
_raw_column="$(xan select $_column $_in_file | tail -n +2 | sort -u)"
|
||||
|
||||
local _count
|
||||
_count=$(echo "$_raw_column" | wc -l)
|
||||
@@ -1352,7 +1352,7 @@ function lib_taxes::__reports_obfs_gen()
|
||||
|
||||
# Generate a temp file of the given raw column
|
||||
local _tmp_file="${_tmp_dir}/${_styled_column}"
|
||||
xsv select "$_column" "$_in_file" -o "$_tmp_file"
|
||||
xan select "$_column" "$_in_file" -o "$_tmp_file"
|
||||
|
||||
# Obfuscate given raw column with keymap data
|
||||
tail -n +2 "$_keymap_file" \
|
||||
@@ -1364,7 +1364,7 @@ function lib_taxes::__reports_obfs_gen()
|
||||
# Join the obfuscated temp files into out file and then delete the temp files.
|
||||
# NOTE: selecting will remove the raw (unobfuscated) columns
|
||||
csvjoin -I --snifflimit 0 "${_tmp_dir}"/* "$_in_file" \
|
||||
| xsv select "$_all_columns" -o "$_out_file"
|
||||
| xan select "$_all_columns" -o "$_out_file"
|
||||
}
|
||||
|
||||
# vim: sw=2 sts=2 si ai et
|
||||
|
||||
Reference in New Issue
Block a user