Update user scripts and table formatting

Add doc annotations to user scripts and refine prompts for user input.
Improve table.jq to use keys_unsorted for header generation.
This commit is contained in:
Chris Kruining 2026-02-17 15:39:55 +01:00
parent 10a1a324ce
commit b72681ff63
No known key found for this signature in database
GPG key ID: EB894A3560CCCAD2
2 changed files with 10 additions and 8 deletions

View file

@ -27,10 +27,9 @@ def to_line(left; joiner; right):
[left, .[0], (.[1:] | map([joiner, .]) ), right] | flatten | join("");
def create(data; header_callback; cell_callback):
(data[0] | to_entries | map(.key)) as $keys
| ([$keys]) as $header
(data[0] | keys_unsorted) as $keys
| (data | map(to_entries | map(.value))) as $rows
| ($header + $rows) as $cells
| ([$keys] + $rows) as $cells
| (
$keys # Use keys so that we have an array of the correct size
| to_entries

View file

@ -2,8 +2,9 @@ set unstable := true
set quiet := true
_default:
just --list
just --list users
[doc('List available users')]
[script]
list:
cd .. && just vars get ulmo zitadel/users | jq -r -C '
@ -25,6 +26,7 @@ list:
| join("\n\n┄┄┄\n\n")
';
[doc('Add a new user')]
[script]
add:
exec 5>&1
@ -47,10 +49,10 @@ add:
jq -r 'to_entries | map(.key)[]' <<< "$data" \
| gum choose --header 'Which organisation to save to?' --select-if-one
`
username=`input 'user name' 'new-user'`
email=`input 'email' 'new.user@example.com'`
first_name=`input 'first name' 'John'`
last_name=`input 'last name' 'Doe'`
username=`input 'user name'`
email=`input 'email'`
first_name=`input 'first name'`
last_name=`input 'last name'`
user_exists=`jq --arg 'org' "$org" --arg 'username' "$username" '.[$org][$username]? | . != null' <<< "$data"`
@ -72,6 +74,7 @@ add:
gum spin --title "saving..." -- echo "$(cd .. && just vars set ulmo 'zitadel/users' "$next")"
[doc('Remove a new user')]
[script]
remove:
data=`cd .. && just vars get ulmo zitadel/users | jq fromjson`