@@ -70,6 +70,9 @@ Commands:
7070 history [--json]
7171 View the current logged in user's list of accessed notes.
7272
73+ info <note_id> [--json]
74+ View the metadata for a given note on the server.
75+
7376Config:
7477 Configuration is set via environment variables (e.g. in ~/.bashrc or shell).
7578
@@ -107,6 +110,8 @@ Usage examples:
107110 \$ $SCRIPTNAME profile
108111 \$ $SCRIPTNAME history
109112 \$ $SCRIPTNAME history --json
113+ \$ $SCRIPTNAME info qhmNmwmxSmK1H2oJmkKBQQ
114+ \$ $SCRIPTNAME info qhmNmwmxSmK1H2oJmkKBQQ --json
110115"
111116
112117
@@ -177,6 +182,75 @@ function import_note() {
177182 echo " $note_id "
178183}
179184
185+ function info_note() {
186+ local note_id=" $1 "
187+ local json=" $2 "
188+
189+ if [[ ! " $note_id " ]]; then
190+ echo " Error: You must specify an export type and note id to export." >&2
191+ echo " " >&2
192+ echo " Usage: $SCRIPTNAME info <note_id> [--json]" >&2
193+ echo " For usage exmaples, see: $SCRIPTNAME help" >&2
194+ return 2
195+ fi
196+
197+ local json=" $2 "
198+
199+ if [[ ! " $note_id " ]]; then
200+ echo " Error: You must specify an export type and note id to export." >&2
201+ echo " " >&2
202+ echo " Usage: $SCRIPTNAME info <note_id> [--json]" >&2
203+ echo " For usage exmaples, see: $SCRIPTNAME help" >&2
204+ return 2
205+ fi
206+
207+ if [[ " $json " == " --json" ]]
208+ then
209+
210+ curl \
211+ --silent \
212+ --cookie " $HEDGEDOC_COOKIES_FILE " \
213+ " ${HEDGEDOC_SERVER} /$note_id /info"
214+
215+ if [[ " $json " == " --json" ]]
216+ then
217+
218+ curl \
219+ --silent \
220+ --cookie " $HEDGEDOC_COOKIES_FILE " \
221+ " ${HEDGEDOC_SERVER} /$note_id /info"
222+
223+ else
224+
225+ response=" $(
226+ curl \
227+ --silent \
228+ --cookie " $HEDGEDOC_COOKIES_FILE " \
229+ " ${HEDGEDOC_SERVER} /$note_id /info" \
230+ | jq ' .title, .description, .viewcount, .createtime, .updatetime' )
231+ )"
232+
233+ SAVEIFS=$IFS
234+ IFS=$' \n '
235+ metadata=( $response )
236+ IFS=$SAVEIFS
237+
238+ for (( i= 0 ; i< ${# metadata[@]} ; i++ ))
239+ do
240+
241+ temp=${metadata[$i]}
242+ temp=${temp// / -}
243+
244+ metadata[$i ]=${temp// \" / }
245+
246+ done
247+
248+ echo ${metadata[@]}
249+
250+ fi
251+
252+ }
253+
180254function export_note() {
181255 local export_type=" ${1# --} " note_id=" ${2:- } " output_path=" ${3:- } "
182256
@@ -392,6 +466,9 @@ function main() {
392466 echo " $help_str "
393467 return 0
394468 ;;
469+ info)
470+ info_note " ${1:- } " " ${2:- } "
471+ ;;
395472 import|import-as)
396473 import_note " ${1:- } " " ${2:- } "
397474 ;;
436513if [[ " ${1:- } " != " --import" ]]; then
437514 main " $@ " || exit $?
438515fi
439-
0 commit comments