summaryrefslogtreecommitdiff
path: root/secrets/list.sh
diff options
context:
space:
mode:
Diffstat (limited to 'secrets/list.sh')
-rwxr-xr-xsecrets/list.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/secrets/list.sh b/secrets/list.sh
new file mode 100755
index 0000000..bf087e3
--- /dev/null
+++ b/secrets/list.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+set -euo pipefail
+
+if [[ "$#" -gt 0 && ("$1" == "-h" || "$1" == "--help") ]]; then
+ cat <<EOF
+list: List all available secrets in the store
+
+Displays all secret names in the global store in a columnar format.
+
+Usage:
+ list
+ list -h|--help
+
+The command will:
+1. List all .age files in the store directory
+2. Remove the .age extension from filenames
+3. Display the secret names in columns
+
+Note: Only shows secret names, not their values.
+EOF
+ exit 0
+fi
+
+this_dir="$(cd "$(dirname "$(realpath "$0")")" && pwd)"
+source "${this_dir}/common.sh"
+
+maybe_column() {
+ if [ -t 1 ]; then
+ column
+ else
+ cat
+ fi
+}
+
+ls "${store}" | sed 's/\.age$//' | sort | maybe_column