projects
/
shutils.git
/ commitdiff
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
c916e38
)
mp-play: use getopt to parse args
author
Stefan Huber <shuber@sthu.org>
Mon, 7 Jan 2013 23:00:29 +0000
(
00:00
+0100)
committer
Stefan Huber <shuber@sthu.org>
Mon, 7 Jan 2013 23:00:29 +0000
(
00:00
+0100)
mp-play
patch
|
blob
|
history
diff --git
a/mp-play
b/mp-play
index cd40b2df1c96e37d94b48b7d109d6e6a13a98076..96e08d9f909ba3b37c25df3ca1f079bb819e8e13 100755
(executable)
--- a/
mp-play
+++ b/
mp-play
@@
-23,22
+23,28
@@
optSorttime=0
function showHelp
{
function showHelp
{
- echo "Plays mp3 files in all subdirectories."
- echo "Usage: ./mp-play.sh [-h|--help] [-R|--random] [-r|--repeat] "
- echo " [-a|-recursive] [--reverse] [--time]"
- echo " [--remove] [-q|--quiet] [-v|--verbose] [DESTINATION]"
+ echo "Usage: $0 [-h|--help]"
+ echo " $0 [OPTIONS] [--] [DESTINATIONS]"
echo ""
echo ""
- echo "Options:"
- echo " --time sort by age of file"
- echo " -R, --random randomize files"
- echo " -r, --repeat repeat playing infintely"
+ echo "OPTIONS:"
echo " -a, --recursive recursively find files to play"
echo " -a, --recursive recursively find files to play"
- echo " --reverse reverse playing order"
- echo " --remove ask to remove played files after playing"
+ echo " -h, --help show this message"
echo " -q, --quiet do not produce output when playing"
echo " -q, --quiet do not produce output when playing"
- echo " -v, --versbose produce more output"
+ echo " -r, --repeat repeat playing infintely"
+ echo " -R, --random randomize files"
+ echo " --remove ask to remove played files after playing"
+ echo " --reverse reverse playing order"
+ echo " --time sort by age of file"
+ echo " -v, --verbose produce more output"
}
}
+if ! options=$(getopt -u -o hRravq -l time,random,repeat,recursive,reverse,remove,quiet,verbose -- "$@")
+then
+ showHelp >&2
+ exit 1
+fi
+set -- $options
+
#Parse the arguments
while [ $# -gt 0 ]
do
#Parse the arguments
while [ $# -gt 0 ]
do
@@
-52,6
+58,8
@@
do
--remove) optRemove=1 ;;
--reverse) optReverse=1 ;;
--time) optSorttime=1 ;;
--remove) optRemove=1 ;;
--reverse) optReverse=1 ;;
--time) optSorttime=1 ;;
+ --) shift; break ;;
+ -*) echo "Unrecognized option $1" >&2; showHelp >&2; exit 1 ;;
*) break ;;
esac
shift
*) break ;;
esac
shift
@@
-64,7
+72,7
@@
if [ "$optRecursive" == "1" ]; then
else
maxlevel=1
fi
else
maxlevel=1
fi
-
+
# Create playlist
find "$@" -maxdepth $maxlevel -type f \
# Create playlist
find "$@" -maxdepth $maxlevel -type f \