Skip to content

Commit

Permalink
src: mail: Adding verbose mode.
Browse files Browse the repository at this point in the history
This commit adds support for the verbose parameter within `kw mail`.
The verbose parameter gives details of the commands that are executed behind the scenes.

Note: This is part of the issue: kworkflow#179

Signed-off-by: Aquila Macedo <aquilamacedo@riseup.net>
  • Loading branch information
aquilamacedo committed Apr 16, 2023
1 parent 89b302d commit 3e8c07f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
4 changes: 4 additions & 0 deletions documentation/man/features/mail.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ SYNOPSIS
| *kw mail* (-l | \--list)
| *kw mail* \--verify [\--local | \--global]
| *kw mail* \--template[=<template>] [-n | \--no-interactive] [\--local | \--global] [-f | \--force] [(<config> <value>)...]
| *kw mail* (-V | \--verbose)
DESCRIPTION
===========
Expand Down Expand Up @@ -116,6 +117,9 @@ OPTIONS
-l, \--list:
Lists the settings that mail uses.

-V, \--verbose:
Verbose mode allows the user to see the commands executed under the hood.

EXAMPLES
========
If you wish to use gmail you can run the following command to setup all the
Expand Down
1 change: 1 addition & 0 deletions src/_kw
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ _kw_mail()
fi

_arguments : \
'(-V --verbose)'{-V,--verbose}'[enable verbose mode]' \
'(-s --send -t --setup -i --interactive -l --list --verify --template)'{-s,--send}'[send a patch by email using git send-email]' \
'(-t --setup -s --send -i --interactive -l --list --verify --template)'{-t,--setup}'[initialize and configure mail functionality]' \
'(-i --interactive -s --send -t --setup -l --list --verify --template)'{-i,--interactive}'[interactively prompt the user for the values of the options]' \
Expand Down
2 changes: 1 addition & 1 deletion src/bash_autocomplete.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function _kw_autocomplete()
kw_options['mail']='--setup --local --global --force --verify --list --email
--name --smtpuser --smtpencryption --smtpserver
--smtpserverport --smtppass --template --interactive
--no-interactive --send --to --cc --simulate --private'
--no-interactive --send --to --cc --simulate --private --verbose'

kw_options['maintainers']='--authors --update-patch'
kw_options['m']="${kw_options['mantainers']}"
Expand Down
22 changes: 16 additions & 6 deletions src/mail.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ declare -gr email_regex='[A-Za-z0-9_\.-]+@[A-Za-z0-9_-]+(\.[A-Za-z0-9]+)+'
#shellcheck disable=SC2119
function mail_main()
{
local flag

if [[ "$1" =~ -h|--help ]]; then
mail_help "$1"
exit 0
Expand All @@ -35,8 +37,10 @@ function mail_main()
return 22 # EINVAL
fi

[[ -n "${options_values['VERBOSE']}" ]] && flag='VERBOSE'

if [[ -n "${options_values['SEND']}" ]]; then
mail_send
mail_send "$flag"
return 0
fi

Expand All @@ -59,12 +63,12 @@ function mail_main()
fi

if [[ -n "${options_values['INTERACTIVE']}" ]]; then
interactive_setup
interactive_setup "$flag"
exit
fi

if [[ "${options_values['SETUP']}" == 1 ]]; then
mail_setup
mail_setup "$flag"
exit
fi

Expand Down Expand Up @@ -911,8 +915,8 @@ function parse_mail_options()
local setup_token=0
local patch_version=''
local commit_count=''
local short_options='s,t,f,v:,i,l,n,'
local long_options='send,simulate,to:,cc:,setup,local,global,force,verify,'
local short_options='s,t,f,v:,i,l,n,V'
local long_options='send,simulate,to:,cc:,setup,local,global,force,verify,verbose,'
long_options+='template::,interactive,no-interactive,list,private,rfc,'
local pass_option_to_send_email

Expand Down Expand Up @@ -950,6 +954,7 @@ function parse_mail_options()
options_values['RFC']=''
options_values['COMMIT_RANGE']=''
options_values['PRIVATE']=''
options_values['VERBOSE']=''

while [[ "$#" -gt 0 ]]; do
case "$1" in
Expand Down Expand Up @@ -1050,6 +1055,10 @@ function parse_mail_options()
options_values['PATCH_VERSION']="$1$2"
shift 2
;;
--verbose | -V)
options_values['VERBOSE']=1
shift
;;
--)
shift
# if a reference is passed after the -- we need to account for it
Expand Down Expand Up @@ -1103,7 +1112,8 @@ function mail_help()
' mail (-i | --interactive) - Setup interactively' \
' mail (-l | --list) - List the configurable options' \
' mail --verify - Check if required configurations are set' \
' mail --template[=<template>] [-n] - Set send-email configs based on <template>'
' mail --template[=<template>] [-n] - Set send-email configs based on <template>' \
' mail (-V | --verbose) - Show a detailed output'
}

load_mail_config

0 comments on commit 3e8c07f

Please sign in to comment.