Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added --tee option #18

Merged
merged 1 commit into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Annotate Terminal based notes managing utility for GNU/Linux OS.
-z|-0 Seperate record(s) by NULL character, instead of NEWLINE(default).
--stdout Do not use pager, just put everything on stdout.
--inc-arch Include archived notes, default is to exclude. Effects list and find actions.
--tee Redirect the captured stdin to stdout. Effects new, and modify actions, and only when
recording note's content through stdin.
--delim [delimiter] Use delimiter to delimit the list output fields.
--format [format] Create custom note listing format with <SNO>,<NID>,<TITLE>,<TAGS>,<GROUP>,<DELIM>.
--sort-as [sf] Use sort flag (sf) to sort the notes listing. sf can be: 'L|l', 'O|o', 'F|f',
Expand Down
10 changes: 9 additions & 1 deletion annote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
###############################################################################

__NAME__='annote'
__VERSION__='2.5.3'
__VERSION__='2.5.4'

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

ERR_CONFIG=1
Expand Down Expand Up @@ -231,6 +232,8 @@ function help {
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)."
log_plain "${idnt_l1}$(as_bold "--stdout")${fsep_3}Do not use pager, just put everything on $(as_bold "stdout")."
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."
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"
log_plain "${idnt_nl_prefx}recording note's content through $(as_bold 'stdin')."
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."
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>")")."
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')',"
Expand Down Expand Up @@ -722,6 +725,7 @@ function add_note {
if [ "x$note" = "x-" ]; then
while IFS= read -r line; do
printf '%s\n' "$line" >> "$nf"
[ "x$flag_tee" = "xy" ] && printf '%s\n' "$line"
done
else
if [ -n "$note" ] && [ -r "$note" ]; then
Expand Down Expand Up @@ -1189,6 +1193,7 @@ function modify_note {
if [ "x$note" = "x-" ]; then
while IFS= read -r line; do
printf '%s\n' "$line" >> "$nf"
[ "x$flag_tee" = "xy" ] && printf '%s\n' "$line"
done
else
if [ -n "$note" ] && [ -r "$note" ]; then
Expand Down Expand Up @@ -2374,6 +2379,9 @@ function parse_args {
"-z"|"-0")
flag_null_sep="y"
;;
"--tee")
flag_tee="y"
;;
"--delim")
store_kv_pair "list_delim=$1"
shift
Expand Down