Skip to content

Commit

Permalink
Add a better command parser
Browse files Browse the repository at this point in the history
Signed-off-by: kernaltrap8 <[email protected]>
  • Loading branch information
kernaltrap8 committed Jul 1, 2024
1 parent 528f739 commit f9b04b9
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/badvideo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# under certain conditions

# Variable setup

VERSION="5.2"
NUM_MP3_PASSES=10
NUM_MP4_PASSES=2
Expand Down Expand Up @@ -34,7 +33,7 @@ check_args() {
exit 0
;;
-h|--help)
echo -e "Usage: $0 [-v] [-h] [-d|--disable-delete] [-D|--debug] [-p1|--mp3-passes] <mp3_passes> [-p2|--mp4-passes] <mp4_passes> [-b1|--mp3-bitrate] <mp3_bitrate> [-b2|--mp4-bitrate] <mp4_bitrate> <input>"
echo -e "Usage: badvideo [-v] [-h] [-d|--disable-delete] [-D|--debug] [-p1|--audio-passes] <audio_passes> [-p2|--video-passes] <video_passes> [-b1|--audio-bitrate] <audio_bitrate> [-b2|--video-bitrate] <video_bitrate> <input>"
exit 0
;;
-d|--disable-delete)
Expand All @@ -45,7 +44,7 @@ check_args() {
ENABLE_DEBUG=1
shift
;;
-p1|--mp3-passes)
-p1|--audio-passes)
if [[ -n "$2" && "$2" != -* ]]; then
NUM_MP3_PASSES="$2"
shift 2
Expand All @@ -54,7 +53,7 @@ check_args() {
exit 1
fi
;;
-p2|--mp4-passes)
-p2|--video-passes)
if [[ -n "$2" && "$2" != -* ]]; then
NUM_MP4_PASSES="$2"
shift 2
Expand All @@ -63,7 +62,7 @@ check_args() {
exit 1
fi
;;
-b1|--mp3-bitrate)
-b1|--audio-bitrate)
if [[ -n "$2" && "$2" != -* ]]; then
MP3_RATE="$2"
shift 2
Expand All @@ -72,7 +71,7 @@ check_args() {
exit 1
fi
;;
-b2|--mp4-bitrate)
-b2|--video-bitrate)
if [[ -n "$2" && "$2" != -* ]]; then
MP4_RATE="$2"
shift 2
Expand All @@ -96,7 +95,7 @@ check_args() {
done

if [ "$#" -lt 1 ]; then
echo -e "No input file supplied.\nPlease supply at least the input filename.\nUsage: $0 [-v] [-h] [-d|--disable-delete] [-D|--debug] [-p1|--mp3-passes] <mp3_passes> [-p2|--mp4-passes] <mp4_passes> [-b1|--mp3-bitrate] <mp3_bitrate> [-b2|--mp4-bitrate] <mp4_bitrate> <input>"
echo -e "No input file supplied.\nPlease supply at least the input filename.\nUsage: badvideo [-v] [-h] [-d|--disable-delete] [-D|--debug] [-p1|--audio-passes] <audio_passes> [-p2|--video-passes] <video_passes> [-b1|--audio-bitrate] <audio_bitrate> [-b2|--video-bitrate] <video_bitrate> <input>"
exit 1
fi

Expand Down

0 comments on commit f9b04b9

Please sign in to comment.