From d8d23ab2ff3949bfd1e4765b53344ab4019553f8 Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Mon, 28 Mar 2022 00:07:43 +0100 Subject: [PATCH] info command --- functions.sh | 12 ++++++++++++ miria-info | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100755 miria-info diff --git a/functions.sh b/functions.sh index 9a90be1..f370389 100644 --- a/functions.sh +++ b/functions.sh @@ -111,6 +111,18 @@ miria_xml_get_string() { echo "${xml}" | xmllint --xpath "string(${xpath})" - } +####################################### +# Get XML string(s) from last answer +# +# Arguments: +# XPath of string +####################################### +miria_last_get_string() { + local xpath="$1" + + miria_xml_get_string "${miria_last_xml}" "//${xpath}" +} + ####################################### # Get XML attribute value(s) # diff --git a/miria-info b/miria-info new file mode 100755 index 0000000..672ff83 --- /dev/null +++ b/miria-info @@ -0,0 +1,38 @@ +################################################################################ +# Copyright 2022 Antonin Portelli +# +# This file is part of miria-cli. +# +# miria-cli is free software: you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# miria-cli is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# miria-cli. If not, see . +################################################################################ + +#!/usr/bin/env bash +set -uoe pipefail + +script_dir=$(dirname $(readlink -f $0)) +source ${script_dir}/functions.sh +hash="$(cd ${script_dir}; git rev-parse --short HEAD)" +branch="$(cd ${script_dir}; git rev-parse --abbrev-ref HEAD)" +status="$(git diff --quiet || echo '(dirty)')" +miria_get_url +echo "Miria CLI ${branch}@${hash} ${status}" +echo 'Copyright 2022 Antonin Portelli' +echo 'GNU General Public License v3' +echo '' +echo '-- Server info -------------' +miria_api_cmd getServerInfo +printf '%s:%s\n' "$(miria_last_get_string '//SERVER_NAME')" \ + "$(miria_last_get_string '//SERVER_PORT')" +miria_last_get_string '//TPE' +miria_last_get_string '//ADA' +echo '----------------------------'