From 4ce2d779fbb72fa6fcc394c897778f6c3f848750 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 23 Nov 2026 00:46:14 +0000 Subject: pkgs/claude-remote: complete --type with the type a remote isn't claude-remote type NAME (for the completion) says its type, so that completion offers --type= only with the other one, and --interactive only for a server (or a new one, which would be a server). --- pkgs/claude-remote.nix | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/pkgs/claude-remote.nix b/pkgs/claude-remote.nix index 48ac7ed..d0da652 100644 --- a/pkgs/claude-remote.nix +++ b/pkgs/claude-remote.nix @@ -726,6 +726,10 @@ let shift exec journalctl -u "$(unit "$n")" "$@" ;; + type) # for the completion + name_arg "''${1-}" + type_of "$1" + ;; names) # for the completion names ;; @@ -751,14 +755,16 @@ let elif [ "''${COMP_WORDS[1]}" = reset ] || [ "''${COMP_WORDS[1]}" = remove ]; then COMPREPLY=($(compgen -W "-f --force" -- "$cur")) elif [ "''${COMP_WORDS[1]}" = start ] || [ "''${COMP_WORDS[1]}" = restart ]; then - # --type=TYPE (which bash splits into --type, =, TYPE) - local prev=''${COMP_WORDS[COMP_CWORD-1]} + # --type=TYPE (which bash splits into --type, =, TYPE): only the + # type it isn't (a new one is a server) + local prev=''${COMP_WORDS[COMP_CWORD-1]} other=interactive + [ "$(claude-remote type "''${COMP_WORDS[2]}" 2>/dev/null)" != interactive ] || other=server if [ "$cur" = = ] && [ "$prev" = --type ]; then - COMPREPLY=(server interactive) + COMPREPLY=($other) elif [ "$prev" = = ] && [ "''${COMP_WORDS[COMP_CWORD-2]}" = --type ]; then - COMPREPLY=($(compgen -W "server interactive" -- "$cur")) + COMPREPLY=($(compgen -W "$other" -- "$cur")) else - COMPREPLY=($(compgen -W "--type= --interactive" -- "$cur")) + COMPREPLY=($(compgen -W "--type= $([ $other = server ] || echo --interactive)" -- "$cur")) [ "''${COMPREPLY[*]}" != --type= ] || compopt -o nospace fi elif [ "''${COMP_WORDS[1]}" = rename ]; then -- cgit v1.3.1