Allow to export note to stdout
This commit is contained in:
parent
fbc7dea378
commit
c533bba79f
2 changed files with 24 additions and 2 deletions
10
notes.sh
10
notes.sh
|
@ -533,7 +533,15 @@ export_note() {
|
|||
FILENAME="$(assert_find_file_by_id "$ID")"
|
||||
|
||||
DIR="$2"
|
||||
if [ -z "$DIR" ]; then
|
||||
DIR="$(mktemp -d)"
|
||||
unpack_mime "$FILENAME" "$DIR"
|
||||
|
||||
cat "$DIR/note.md"
|
||||
rm -rf "$DIR"
|
||||
else
|
||||
unpack_mime "$FILENAME" "$DIR"
|
||||
fi
|
||||
}
|
||||
|
||||
get_raw_graph() {
|
||||
|
@ -620,7 +628,7 @@ while (( "$#" )); do
|
|||
exit 0
|
||||
;;
|
||||
-E|--export)
|
||||
if [ -z "$2" ] || [ -z "$3" ]; then
|
||||
if [ -z "$2" ]; then
|
||||
echo "Misssing arguments for $1"
|
||||
exit 1
|
||||
fi
|
||||
|
|
14
test.sh
14
test.sh
|
@ -147,6 +147,19 @@ export_note() {
|
|||
assert 'cat out/note.md | grep Subject' "Subject: header1"
|
||||
}
|
||||
|
||||
export_note_stdout() {
|
||||
"$BASE_DIR/notes.sh" -n <<- EOF
|
||||
Subject: header1
|
||||
|
||||
# This is a body
|
||||
EOF
|
||||
NOTE_ID="$(cat "$(pwd)/notes/cur"/* | grep X-Note-Id | cut -d ' ' -f 2)"
|
||||
|
||||
MD="$("$BASE_DIR/notes.sh" -E "$NOTE_ID")"
|
||||
|
||||
assert 'echo "$MD" | grep Subject' "Subject: header1"
|
||||
}
|
||||
|
||||
edit_note() {
|
||||
"$BASE_DIR/notes.sh" -n <<- EOF
|
||||
Subject: header1
|
||||
|
@ -460,6 +473,7 @@ testcase new_note_from_file
|
|||
testcase new_note_from_dir
|
||||
testcase list_notes
|
||||
testcase export_note
|
||||
testcase export_note_stdout
|
||||
testcase edit_note
|
||||
testcase edit_note_add_file
|
||||
testcase edit_note_no_modifications
|
||||
|
|
Loading…
Reference in a new issue