From 7fa5ca25684430e10a4c85b54599a8c7a48cc5bc Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 17 Aug 2026 20:19:42 -0400 Subject: [PATCH] feat(config): add component registry lookup helper --- .../__fish_config_op_registry_lookup.fish | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 functions/__fish_config_op_registry_lookup.fish diff --git a/functions/__fish_config_op_registry_lookup.fish b/functions/__fish_config_op_registry_lookup.fish new file mode 100644 index 0000000..ddee75a --- /dev/null +++ b/functions/__fish_config_op_registry_lookup.fish @@ -0,0 +1,38 @@ +# Copyright (C) 2026 Rootiest +# SPDX-License-Identifier: AGPL-3.0-or-later + +# SYNOPSIS +# __fish_config_op_registry_lookup +# +# DESCRIPTION +# Looks up the ":" key in the generated component +# registry ($__fish_config_op_registry_keys / +# $__fish_config_op_registry_values, sourced from +# conf.d/__fish_config_op_registry.fish at shell startup) and prints its +# tags, one per line. is empty string for the default/unnamed +# site. +# +# ARGUMENTS +# identity Function name (status current-function) or file basename +# with any trailing .fish stripped (status basename) +# site Site slug, or empty string for the default site +# +# EXIT STATUS +# 0 Found: tags printed to stdout +# 1 Not found: nothing printed +# +# RETURNS +# Matching tags, one per line, printed to stdout +# +# EXAMPLE +# set -l tags (__fish_config_op_registry_lookup rm "") +# or return 0 # unclassified: caller treats this as always-on +function __fish_config_op_registry_lookup --description 'Look up the COMPONENT tags for an identity:site pair' + set -l key "$argv[1]:$argv[2]" + set -l idx (contains -i -- $key $__fish_config_op_registry_keys) + if test -z "$idx" + return 1 + end + string split ' ' -- $__fish_config_op_registry_values[$idx] + return 0 +end