Skip to content

Commit 71e522a

Browse files
revert formatting changes
1 parent e11c7df commit 71e522a

File tree

3 files changed

+81
-79
lines changed

3 files changed

+81
-79
lines changed

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ Renames a given note to destination or moves the note to directory. Name can be
147147
Removes the given note if it exists. If `-r` or `--recursive` is given, deletes the folders/notes recursively.
148148

149149
### `notes cat <note-name>`
150-
Shorthand alias also available with `notes c`.
151-
Displays the note
150+
Displays the note. Shorthand alias also available with `notes c`.
152151

153152
### `notes grep/find <pattern> | notes open`
154153

notes

100755100644
+68-65
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ search_filenames_and_contents() {
5656
"shopt -s nocasematch
5757
grep -il \"$*\" \"{}\" || if [[ \"{}\" =~ \"$*\" ]]; then
5858
echo \"{}\";
59-
fi" \;)
59+
fi" \;\
60+
)
6061
else
6162
find_output=$(find "$notes_dir" -type f)
6263
fi
@@ -104,11 +105,12 @@ grep_notes() {
104105

105106
generate_name() {
106107
local append_num=0
107-
local format_string="$(date +$QUICKNOTE_FORMAT)"
108+
local format_string="`date +$QUICKNOTE_FORMAT`"
108109
# Initial test has no append
109110
local resolved_name=$format_string
110-
while [[ -e "$notes_dir/$resolved_name.$NOTES_EXT" ]]; do
111-
append_num=$(($append_num + 1))
111+
while [[ -e "$notes_dir/$resolved_name.$NOTES_EXT" ]]
112+
do
113+
append_num=$[$append_num+1]
112114
resolved_name=$format_string.$append_num
113115
done
114116
printf $resolved_name
@@ -117,10 +119,10 @@ generate_name() {
117119
new_note() {
118120
local note_name="$*"
119121
if [[ $note_name == "" ]]; then
120-
note_name="$(generate_name)"
122+
note_name="$(generate_name)"
121123
fi
122124

123-
if echo "$note_name" | grep "/$" &>/dev/null; then
125+
if echo "$note_name" | grep "/$" &> /dev/null; then
124126
note_name="${note_name}/$(generate_name)"
125127
fi
126128

@@ -159,7 +161,7 @@ handle_multiple_notes() {
159161
read -d'\n' note_names
160162
while read note_name; do
161163
${cmd}_note "$note_name"
162-
done <<<"$note_names"
164+
done <<< "$note_names"
163165
else
164166
${cmd}_note "${@:2}"
165167
fi
@@ -200,7 +202,7 @@ open_note() {
200202
exit 1
201203
fi
202204

203-
note_path=$(get_full_note_path "$note_path")
205+
note_path=$( get_full_note_path "$note_path" )
204206

205207
if bash -c ": >/dev/tty" >/dev/null 2>/dev/null; then
206208
$EDITOR "$note_path" </dev/tty
@@ -210,7 +212,7 @@ open_note() {
210212
}
211213

212214
append_note() {
213-
local source_note_path=$(get_full_note_path "$1")
215+
local source_note_path=$( get_full_note_path "$1" )
214216
local to_append="${@:2}"
215217

216218
# If no note name was provided, exit
@@ -235,11 +237,11 @@ append_note() {
235237
exit 1
236238
fi
237239

238-
echo "$to_append" >>"$source_note_path"
240+
echo "$to_append" >> "$source_note_path"
239241
}
240242

241243
move_note() {
242-
local source_note_path=$(get_full_note_path "$1")
244+
local source_note_path=$( get_full_note_path "$1" )
243245
local dest_or_dir_path=$2
244246

245247
if [[ ! -e "$source_note_path" ]]; then
@@ -258,8 +260,8 @@ move_note() {
258260
return
259261
fi
260262

261-
local dest_path=$(get_full_note_path "$dest_or_dir_path")
262-
mkdir -p "$(dirname $dest_path)"
263+
local dest_path=$( get_full_note_path "$dest_or_dir_path" )
264+
mkdir -p "$( dirname $dest_path)"
263265
mv $source_note_path $dest_path
264266
}
265267

@@ -271,14 +273,14 @@ cat_note() {
271273
exit 1
272274
fi
273275

274-
note_path=$(get_full_note_path "$note_path")
276+
note_path=$( get_full_note_path "$note_path" )
275277

276278
cat "$note_path"
277279
}
278280

279281
usage() {
280-
local name=$(basename $0)
281-
cat <<EOF
282+
local name=$(basename $0)
283+
cat <<EOF
282284
$name is a command line note taking tool.
283285
284286
Usage:
@@ -305,8 +307,8 @@ EOF
305307
}
306308

307309
version() {
308-
local name=$(basename $0)
309-
cat <<EOF
310+
local name=$(basename $0)
311+
cat <<EOF
310312
$name $notes_version
311313
EOF
312314
}
@@ -324,57 +326,57 @@ main() {
324326
fi
325327

326328
case "$1" in
327-
"new" | "n")
328-
cmd="new_note"
329-
modified=1
330-
;;
331-
"ls")
332-
cmd="ls_notes"
333-
;;
334-
"search" | "s")
335-
cmd="search_filenames_and_contents"
336-
;;
337-
"find" | "f")
338-
cmd="find_notes"
339-
;;
340-
"grep" | "g")
341-
cmd="grep_notes"
342-
;;
343-
"open" | "o")
344-
cmd="handle_multiple_notes open"
345-
modified=1
346-
;;
347-
"append" | "a")
348-
cmd="append_note"
349-
modified=1
350-
;;
351-
"mv")
352-
cmd="move_note"
353-
modified=1
354-
;;
355-
"rm")
356-
cmd="remove_note"
357-
modified=1
358-
;;
359-
"cat" | "c")
360-
cmd="handle_multiple_notes cat"
361-
;;
362-
--help | -help | -h)
363-
cmd="usage"
364-
;;
365-
--version | -version)
366-
cmd="version"
367-
;;
368-
*)
369-
printf "$1 is not a recognized notes command.\n\n"
370-
cmd="usage"
371-
ret=1
372-
;;
329+
"new"|"n" )
330+
cmd="new_note"
331+
modified=1
332+
;;
333+
"ls" )
334+
cmd="ls_notes"
335+
;;
336+
"search"|"s" )
337+
cmd="search_filenames_and_contents"
338+
;;
339+
"find"|"f" )
340+
cmd="find_notes"
341+
;;
342+
"grep"|"g" )
343+
cmd="grep_notes"
344+
;;
345+
"open"|"o" )
346+
cmd="handle_multiple_notes open"
347+
modified=1
348+
;;
349+
"append"|"a" )
350+
cmd="append_note"
351+
modified=1
352+
;;
353+
"mv" )
354+
cmd="move_note"
355+
modified=1
356+
;;
357+
"rm" )
358+
cmd="remove_note"
359+
modified=1
360+
;;
361+
"cat" | "c" )
362+
cmd="handle_multiple_notes cat"
363+
;;
364+
--help | -help | -h )
365+
cmd="usage"
366+
;;
367+
--version | -version )
368+
cmd="version"
369+
;;
370+
* )
371+
printf "$1 is not a recognized notes command.\n\n"
372+
cmd="usage"
373+
ret=1
374+
;;
373375
esac
374376
shift
375377

376378
$cmd "$@"
377-
ret=$(($ret + $?))
379+
ret=$[$ret+$?]
378380

379381
# run POST_COMMAND hook when modification cmd succeeds
380382
if [ $ret -eq 0 ] && [ $modified -eq 1 ] && [ -n "$POST_COMMAND" ]; then
@@ -384,3 +386,4 @@ main() {
384386
exit $ret
385387
}
386388
main "$@"
389+

test/test-cat.bats

100755100644
+12-12
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,26 @@ teardown() {
1313
notes="./notes"
1414

1515
@test "Should show created note" {
16-
echo line1 >>"$NOTES_DIRECTORY/note.md"
17-
echo line2 >>"$NOTES_DIRECTORY/note.md"
16+
echo line1 >> "$NOTES_DIRECTORY/note.md"
17+
echo line2 >> "$NOTES_DIRECTORY/note.md"
1818
run $notes cat note.md
1919

2020
assert_success
2121
assert_output $'line1\nline2'
2222
}
2323

2424
@test "Should show created note when using the cat shorthand alias" {
25-
echo line1 >>"$NOTES_DIRECTORY/note.md"
26-
echo line2 >>"$NOTES_DIRECTORY/note.md"
25+
echo line1 >> "$NOTES_DIRECTORY/note.md"
26+
echo line2 >> "$NOTES_DIRECTORY/note.md"
2727
run $notes c note.md
2828

2929
assert_success
3030
assert_output $'line1\nline2'
3131
}
3232

3333
@test "Accepts names without .md to show" {
34-
echo line1 >>"$NOTES_DIRECTORY/note.md"
35-
echo line2 >>"$NOTES_DIRECTORY/note.md"
34+
echo line1 >> "$NOTES_DIRECTORY/note.md"
35+
echo line2 >> "$NOTES_DIRECTORY/note.md"
3636
run $notes cat note
3737

3838
assert_success
@@ -46,17 +46,17 @@ notes="./notes"
4646
}
4747

4848
@test "Accepts relative notes paths to show" {
49-
echo line1 >>"$NOTES_DIRECTORY/note.md"
50-
echo line2 >>"$NOTES_DIRECTORY/note.md"
49+
echo line1 >> "$NOTES_DIRECTORY/note.md"
50+
echo line2 >> "$NOTES_DIRECTORY/note.md"
5151
run $notes cat $NOTES_DIRECTORY/note.md
5252

5353
assert_success
5454
assert_output $'line1\nline2'
5555
}
5656

5757
@test "Show a file passed by pipe from find" {
58-
echo line1 >>"$NOTES_DIRECTORY/note.md"
59-
echo line2 >>"$NOTES_DIRECTORY/note.md"
58+
echo line1 >> "$NOTES_DIRECTORY/note.md"
59+
echo line2 >> "$NOTES_DIRECTORY/note.md"
6060

6161
run bash -c "$notes find | $notes cat"
6262

@@ -65,8 +65,8 @@ notes="./notes"
6565
}
6666

6767
@test "Show multiple files passed by pipe from find" {
68-
echo line1 >>"$NOTES_DIRECTORY/note1.md"
69-
echo line2 >>"$NOTES_DIRECTORY/note2.md"
68+
echo line1 >> "$NOTES_DIRECTORY/note1.md"
69+
echo line2 >> "$NOTES_DIRECTORY/note2.md"
7070

7171
run bash -c "$notes find | $notes cat"
7272

0 commit comments

Comments
 (0)