Skip to content

Commit d229625

Browse files
author
Dark Decoy
committed
Updated default output to be formatted
Updated --raw option which returns bash array
1 parent a6e6291 commit d229625

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

bin/hedgedoc

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ function import_note() {
184184

185185
function info_note() {
186186
local note_id="$1"
187-
local json="$2"
187+
local option="$2"
188188

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

197-
if [[ "$json" == "--json" ]]
197+
if [[ "$option" == "--json" ]]
198198
then
199199

200200
curl \
201201
--silent \
202202
--cookie "$HEDGEDOC_COOKIES_FILE" \
203203
"${HEDGEDOC_SERVER}/$note_id/info"
204204

205-
else
205+
elif [[ "$option" == "--raw" ]]
206206

207207
response="$(
208208
curl \
@@ -229,6 +229,26 @@ function info_note() {
229229

230230
echo ${metadata[@]}
231231

232+
else
233+
234+
response="$(
235+
curl \
236+
--silent \
237+
--cookie "$HEDGEDOC_COOKIES_FILE" \
238+
"${HEDGEDOC_SERVER}/$note_id/info"
239+
)"
240+
title=$(echo "$response" | jq -r .title)
241+
description=$(echo "$response" | jq -r .description)
242+
viewcount=$(echo "$response" | jq -r .viewcount)
243+
createtime=$(date -d $(echo "$response" | jq -r .createtime))
244+
updatetime=$(date -d $(echo "$response" | jq -r .updatetime))
245+
246+
echo "Title: ${title}"
247+
echo "Description: ${description}"
248+
echo "Viewcount: ${viewcount}"
249+
echo "Created: ${createtime}"
250+
echo "Updated: ${updatetime}"
251+
232252
fi
233253

234254
}

0 commit comments

Comments
 (0)