[script] log_editor use menu to select date

This commit is contained in:
Mathieu Maret 2011-09-16 16:21:13 +02:00
parent f24288b7df
commit acd9136710

View File

@ -19,12 +19,9 @@ HPD=24
mode_available="view edit list toMail" mode_available="view edit list toMail"
usage () { usage () {
echo "usage : $0 mode [date] " echo "usage : ${0##*/} MODE [DATE|select] "
echo "with mode in :" echo -e "\twith MODE in : $mode_available"
for i in $mode_available; echo -e "\tDATE format is YYYY_MM_DD"
do
echo -e "$i "
done
echo "" echo ""
} }
@ -88,8 +85,9 @@ edit () {
${EDITOR} $log_directory/$date_to_edit ${EDITOR} $log_directory/$date_to_edit
} }
list () { list () {
logs=$(ls $log_directory | sort) logs=$(ls $log_directory | sort -r )
echo "${logs}" echo "${logs}"
} }
@ -111,7 +109,26 @@ valid=$?
if [[ $# -ge 1 && $valid = 1 ]] if [[ $# -ge 1 && $valid = 1 ]]
then then
eval $1 $2 date=$2
if [[ "$2" = "select" ]]
then
PS3='Choose Your Date '
logs=$(ls $log_directory | sort -r)
select date in $logs quit
do
echo
echo "date $date selected"
echo
break
done
if [[ "$date" == "quit" ]]
then
echo "Exiting"
exit 0
fi
fi
eval $1 $date
else else
usage usage
fi fi