Skip to content

Commit

Permalink
Automate config.toml edition through script
Browse files Browse the repository at this point in the history
  • Loading branch information
dcadenas committed Aug 2, 2024
1 parent c5eca5d commit 41814e0
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion npubsToPubkeys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,31 @@ fi

input_file="$1"

cat $input_file | xargs nak decode | jq .pubkey | sed 's/$/,/' | sed 's/^/ /' | pbcopy
# Get the current month, day, and time period
current_month=$(date +%B)
current_day=$(date +%-d)
time_period=$(date +%p | tr '[:upper:]' '[:lower:]')

# Construct the comment line
comment_line=" # $current_month $current_day $time_period"

# Read the file and transform it
cat "$input_file" | while IFS= read -r line; do
# Skip empty lines
[ -z "$line" ] && continue
# Extract the first string of each line
first_string=$(echo "$line" | awk '{print $1}')
# Decode the first string and transform it
pubkey=$(echo "$first_string" | nak decode | jq -r .pubkey)
echo " \"$pubkey\", # $first_string"
done | pbcopy

# Open config.toml in vim and paste the clipboard content
vim config.toml -c '/pubkey_whitelist_readers' -c "normal o" -c "normal k" -c "normal o$comment_line" -c 'normal "+p' -c 'wq'

echo config.toml was edited with new pubkeys, verify and commit \n
git diff




0 comments on commit 41814e0

Please sign in to comment.