From 4c3daa723b8afd6642546fc7e534361f3d385dff Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Wed, 9 Oct 2024 14:31:10 +0200 Subject: [PATCH] fix: [vps] provide better help support for stats, listing available resources --- bin/vps | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/vps b/bin/vps index b00c625..a78e6ea 100755 --- a/bin/vps +++ b/bin/vps @@ -2168,13 +2168,17 @@ awk:require() { done } +resource:list() { + declare -F | egrep -- '-fx? stats:[a-zA-Z0-9_.-]+$' | cut -f 3- -d " " | cut -f 2- -d ":" +} cmdline.spec.gnu stats cmdline.spec::cmd:stats:run() { : :optval: --format,-f "Either 'silent', 'raw', or 'pretty', default is pretty." : :optfla: --silent,-s "Shorthand for '--format silent'" - : :optval: --resource,-r 'resource(s) separated with a comma' + : :optval: --resource,-r "resource(s) separated with a comma + (available resources: $(resource:list))" local project_name service_name containers container check @@ -2222,7 +2226,7 @@ cmdline.spec::cmd:stats:run() { not_found_msg=${not_found_msg%, } err "Unsupported resource(s) provided: ${not_found_msg}" echo " resource must be one-of:" >&2 - declare -F | egrep -- '-fx? stats:[a-zA-Z0-9_.-]+$' | cut -f 3- -d " " | cut -f 2- -d ":" | prefix " - " >&2 + resource:list | prefix " - " >&2 return 1 fi