Skip to content

Commit

Permalink
Updated default output to be formatted
Browse files Browse the repository at this point in the history
Updated --raw option which returns bash array
  • Loading branch information
Dark Decoy committed Mar 14, 2023
1 parent a6e6291 commit d229625
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions bin/hedgedoc
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ function import_note() {

function info_note() {
local note_id="$1"
local json="$2"
local option="$2"

if [[ ! "$note_id" ]]; then
echo "Error: You must specify a note id to retrieve metadata from the server." >&2
Expand All @@ -194,15 +194,15 @@ function info_note() {
return 2
fi

if [[ "$json" == "--json" ]]
if [[ "$option" == "--json" ]]
then

curl \
--silent \
--cookie "$HEDGEDOC_COOKIES_FILE" \
"${HEDGEDOC_SERVER}/$note_id/info"

else
elif [[ "$option" == "--raw" ]]

response="$(
curl \
Expand All @@ -229,6 +229,26 @@ function info_note() {

echo ${metadata[@]}

else

response="$(
curl \
--silent \
--cookie "$HEDGEDOC_COOKIES_FILE" \
"${HEDGEDOC_SERVER}/$note_id/info"
)"
title=$(echo "$response" | jq -r .title)
description=$(echo "$response" | jq -r .description)
viewcount=$(echo "$response" | jq -r .viewcount)
createtime=$(date -d $(echo "$response" | jq -r .createtime))
updatetime=$(date -d $(echo "$response" | jq -r .updatetime))

echo "Title: ${title}"
echo "Description: ${description}"
echo "Viewcount: ${viewcount}"
echo "Created: ${createtime}"
echo "Updated: ${updatetime}"

fi

}
Expand Down

0 comments on commit d229625

Please sign in to comment.