Skip to content

Commit 682b802

Browse files
authored
Merge pull request #18 from dineshsaini/main
added --tee option
2 parents f36ee42 + 4b4faf4 commit 682b802

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ Annotate Terminal based notes managing utility for GNU/Linux OS.
2424
-z|-0 Seperate record(s) by NULL character, instead of NEWLINE(default).
2525
--stdout Do not use pager, just put everything on stdout.
2626
--inc-arch Include archived notes, default is to exclude. Effects list and find actions.
27+
--tee Redirect the captured stdin to stdout. Effects new, and modify actions, and only when
28+
recording note's content through stdin.
2729
--delim [delimiter] Use delimiter to delimit the list output fields.
2830
--format [format] Create custom note listing format with <SNO>,<NID>,<TITLE>,<TAGS>,<GROUP>,<DELIM>.
2931
--sort-as [sf] Use sort flag (sf) to sort the notes listing. sf can be: 'L|l', 'O|o', 'F|f',

annote.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
###############################################################################
66

77
__NAME__='annote'
8-
__VERSION__='2.5.3'
8+
__VERSION__='2.5.4'
99

1010
# variables
1111
c_red="$(tput setaf 196)"
@@ -69,6 +69,7 @@ flag_list_find="" # 'y' --> to show list of notes not
6969
flag_show_archived="" # 'y' --> include archived notes into list/find, blank to exclude
7070
flag_no_header="" # 'y' --> to remove header from output
7171
flag_null_sep="" # 'y' --> to seperate records by null, empty to seperate by newline
72+
flag_tee="" # 'y' --> tee the captured stdin to the stdout
7273
flag_debug_mutex_ops="$DBG_MUTEX_OPS" # 'y'|'yes' --> enable mutex multi opts execution, PS: supplying multi opts can creates confusion.
7374

7475
ERR_CONFIG=1
@@ -231,6 +232,8 @@ function help {
231232
log_plain "${idnt_l1}$(as_bold "-z")|$(as_bold "-0")${fsep_4}Seperate record(s) by $(as_dim "NULL") character, instead of $(as_dim "NEWLINE")(default)."
232233
log_plain "${idnt_l1}$(as_bold "--stdout")${fsep_3}Do not use pager, just put everything on $(as_bold "stdout")."
233234
log_plain "${idnt_l1}$(as_bold "--inc-arch")${fsep_3}Include archived notes, default is to exclude. Effects $(as_bold "list") and $(as_bold "find") actions."
235+
log_plain "${idnt_l1}$(as_bold "--tee")${fsep_4}Redirect the captured $(as_bold 'stdin') to $(as_bold 'stdout'). Effects $(as_bold 'new'), and $(as_bold 'modify') actions, and only when"
236+
log_plain "${idnt_nl_prefx}recording note's content through $(as_bold 'stdin')."
234237
log_plain "${idnt_l1}$(as_bold "--delim") [$(as_bold "$(as_light_green "delimiter")")]${fsep_2}Use $(as_bold "$(as_light_green "delimiter")") to delimit the list output fields."
235238
log_plain "${idnt_l1}$(as_bold "--format") [$(as_bold "$(as_light_green "format")")]${fsep_2}Create custom $(as_underline "note listing") format with $(as_dim "$(as_underline "<SNO>")"),$(as_dim "$(as_underline "<NID>")"),$(as_dim "$(as_underline "<TITLE>")"),$(as_dim "$(as_underline "<TAGS>")"),$(as_dim "$(as_underline "<GROUP>")"),$(as_dim "$(as_underline "<DELIM>")")."
236239
log_plain "${idnt_l1}$(as_bold "--sort-as") [$(as_bold "$(as_light_green "sf")")]${fsep_3}Use sort flag ($(as_bold "$(as_light_green "sf")")) to sort the notes listing. $(as_bold "$(as_light_green "sf")") can be: '$(as_dim 'L')|$(as_dim 'l')', '$(as_dim 'O')|$(as_dim 'o')', '$(as_dim 'F')|$(as_dim 'f')',"
@@ -722,6 +725,7 @@ function add_note {
722725
if [ "x$note" = "x-" ]; then
723726
while IFS= read -r line; do
724727
printf '%s\n' "$line" >> "$nf"
728+
[ "x$flag_tee" = "xy" ] && printf '%s\n' "$line"
725729
done
726730
else
727731
if [ -n "$note" ] && [ -r "$note" ]; then
@@ -1189,6 +1193,7 @@ function modify_note {
11891193
if [ "x$note" = "x-" ]; then
11901194
while IFS= read -r line; do
11911195
printf '%s\n' "$line" >> "$nf"
1196+
[ "x$flag_tee" = "xy" ] && printf '%s\n' "$line"
11921197
done
11931198
else
11941199
if [ -n "$note" ] && [ -r "$note" ]; then
@@ -2374,6 +2379,9 @@ function parse_args {
23742379
"-z"|"-0")
23752380
flag_null_sep="y"
23762381
;;
2382+
"--tee")
2383+
flag_tee="y"
2384+
;;
23772385
"--delim")
23782386
store_kv_pair "list_delim=$1"
23792387
shift

0 commit comments

Comments
 (0)