From bf11241649cc0ef7bea4188d9baf880b0ea95276 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Sat, 21 Dec 2024 21:13:53 +0900 Subject: [PATCH] fortify: zsh complete show instance list Signed-off-by: Ophestra --- comp/_fortify | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/comp/_fortify b/comp/_fortify index b7e97c2..d45f9da 100644 --- a/comp/_fortify +++ b/comp/_fortify @@ -1,7 +1,8 @@ #compdef fortify _fortify_app() { - _path_files -g "*.(json|ftfy)" + __fortify_files + return $? } _fortify_run() { @@ -26,6 +27,29 @@ _fortify_ps() { '--short[Print instance id]' } +_fortify_show() { + _alternative \ + 'instances:domains:__fortify_instances' \ + 'files:files:__fortify_files' +} + +__fortify_files() { + _files -g "*.(json|ftfy)" + return $? +} + +__fortify_instances() { + local -a out + shift -p + out=( ${(f)"$(_call_program commands fortify ps --short 2>&1)"} ) + if (( $#out == 0 )); then + _message "No active instances" + else + _describe "active instances" out + fi + return $? +} + (( $+functions[_fortify_commands] )) || _fortify_commands() { local -a _fortify_cmds