Debian Codegraph @

src/functions/format.sh

raw
1 #!/usr/bin/env bash
2 # shellcheck disable=SC2154,SC2034
3 # these top lines are moved during build
4
5 # format
6 format() {
7 list="cli csv xml json"
8 if [[ -n "${output_format}" ]]; then
9 if [[ ! ${list} =~ ${output_format} ]]; then
10 printf "\033[31mError: Please provide a valid format {cli, csv, xml, json}.\033[m\n\n"
11 exit 1
12 fi
13 fi
14 if [[ "${output_format}" == "xml" ]]; then
15 echo '<?xml version="1.0" encoding="UTF-8"?>'
16 fi
17 format="${output_format}"
18 }