[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
1 changed files with 25 additions and 8 deletions

View File

@ -19,12 +19,9 @@ HPD=24
mode_available="view edit list toMail"
usage () {
echo "usage : $0 mode [date] "
echo "with mode in :"
for i in $mode_available;
do
echo -e "$i "
done
echo "usage : ${0##*/} MODE [DATE|select] "
echo -e "\twith MODE in : $mode_available"
echo -e "\tDATE format is YYYY_MM_DD"
echo ""
}
@ -88,8 +85,9 @@ edit () {
${EDITOR} $log_directory/$date_to_edit
}
list () {
logs=$(ls $log_directory | sort)
logs=$(ls $log_directory | sort -r )
echo "${logs}"
}
@ -111,7 +109,26 @@ valid=$?
if [[ $# -ge 1 && $valid = 1 ]]
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
usage
fi