diff options
| author | Caroline Larimore <caroline@larimo.re> | 2025-11-27 12:33:55 -0800 |
|---|---|---|
| committer | Caroline Larimore <caroline@larimo.re> | 2025-11-27 12:33:55 -0800 |
| commit | 5a683c455863dac52bb88af301a2f4987136c963 (patch) | |
| tree | 101c81c02c21d2224617f3e6293b2fbb796f3e6b | |
| parent | e16c4722335cc8ee4c198144d6c2cb20b7265ad0 (diff) | |
refactor: reformat profile json
| -rwxr-xr-x | mcsh.sh | 26 |
1 files changed, 24 insertions, 2 deletions
@@ -157,8 +157,30 @@ function update_profile ( exit 1 fi - #TODO: hyphenate uuid, for :sparkles: style :sparkles: - profiles="$(<<<"$res" jq --arg profile "$profile" --slurpfile profiles "$DATA_DIR/profiles.json" '$profiles[0] + {"\(.name)": $profiles[0].[$profile] + {"username": .name, "uuid": .id}} | del(.["<unknown>"])')" + uuid="$(<<<"$res" jq -r '.id')" + uuid="${uuid:0:8}-${uuid:8:4}-${uuid:12:4}-${uuid:16:4}-${uuid:20:12}" + + profiles="$( + <<<"$res" jq \ + --arg profile "$profile" \ + --arg uuid "$uuid" \ + --slurpfile profiles "$DATA_DIR/profiles.json" \ + '$profiles[0].[$profile] as $prev + | $profiles[0] + { + "\(.name)": { + "username": .name, + "uuid": $uuid, + "xuid": $prev.xuid, + "type": $prev.type, + "skins": .skins, + "capes": .capes, + "refresh_token": $prev.refresh_token, + "xbl_token": $prev.xbl_token, + "mc_token": $prev.mc_token + } + } + | del(.["<unknown>"])' + )" <<<"$profiles" cat > "$DATA_DIR/profiles.json" jq --arg profile "$profile" '.[$profile]' "$DATA_DIR/profiles.json" |