diff --git a/music-sync.sh b/music-sync.sh index b34b709..e685ac3 100755 --- a/music-sync.sh +++ b/music-sync.sh @@ -1,4 +1,38 @@ #!/bin/bash +# +#/ +#/ Usage: +#/ music-sync -s|--source -d|--dest +#/ music-sync +#/ +#/ Syncronises music from one folder to another. +#/ +#/ Options: +#/ -s, --source The source folder of the music +#/ -d, --dest The destination folder of the music +#/ -t, --temp The temporary cache for converted files (default: /tmp/converted) +#/ -c, --convert Convert files to a given bitrate in kbps before syncing (default: 192) +#/ -a, --resize-art Resize album-art before syncing (default width: 200) +#/ -j, --jobs Number of processes to use in multi-threading (default: CPU_CORES - 2) +#/ -v, --verbose <0-6> Set log level (default: 2) +#/ -h, --help Display this help text +#/ +#/ Log levels: +#/ 0 | Verbose +#/ 1 | Debug +#/ 2 | Info +#/ 3 | Warning +#/ 4 | Error +#/ 5 | Fatal +#/ 6 | Silence +#/ +#/ Exit Codes: +#/ 1 Dependencies not met +#/ 2 Invalid Argument +#/ 3 Source Unreachable +#/ 4 Destination Unreachable +#/ 5 Command failed +#/ begin=$(date +"%s") # saner programming env: these switches turn some bugs into errors @@ -14,6 +48,8 @@ convertart=false coverartsize=200 jobcount="-2" multithread=false +script_name=$(basename "${0}") +script_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) CheckDeps() { if [[ $1 == 0 ]]; then @@ -198,38 +234,7 @@ GetOptions() { } Usage() { - echo "" - echo "Usage:" - echo "music-sync -s|--source -d|--dest " - echo "music-sync " - echo "" - echo "Syncronises music from one folder to another." - echo "" - echo "Options:" - echo " -s, --source The source folder of the music" - echo " -d, --dest The destination folder of the music" - echo " -t, --temp The temporary cache for converted files (default: /tmp/converted)" - echo " -c, --convert Convert files to a given bitrate in kbps before syncing (default: 192)" - echo " -a, --resize-art Resize album-art before syncing (default width: 200)" - echo " -v, --verbose <0-6> Set log level (default: 2)" - echo " -h, --help Display this help text" - echo "" - echo "Log levels:" - echo " 0 | Verbose" - echo " 1 | Debug" - echo " 2 | Info" - echo " 3 | Warning" - echo " 4 | Error" - echo " 5 | Fatal" - echo " 6 | Silence" - echo "" - echo "Exit Codes:" - echo " 1 Dependencies not met" - echo " 2 Invalid Argument" - echo " 3 Source Unreachable" - echo " 4 Destination Unreachable" - echo " 5 Command failed" - echo "" + grep '^#/' "${script_dir}/${script_name}" | sed 's/^#\/\w*//' } VerboseOutput() {