Browse Source

Add version (`-V`) option

Matteo Savatteri 3 years ago
parent
commit
428439102d
1 changed files with 19 additions and 3 deletions
  1. 19 3
      vaporget

+ 19 - 3
vaporget

@@ -17,9 +17,12 @@
 
 # Global Variables
 PROGRAM_NAME="vaporget"
+PROGRAM_VERSION="0.1-alpha"
+PROGRAM_UPSTREAM="https://lcm.mi.infn.it/gogs/matteozeccolimarazzini/vaporget.git"
+AUTHOR_NAME="Matteo Savatteri and Matteo Zeccoli Marazzini"
 WEBSITE="https://vaporwave.ivan.moe/list/"
 MODE="play"
-USAGE="Usage: $PROGRAM_NAME [-pdh] [-m MPV_OPTION,...]"
+USAGE="Usage: $PROGRAM_NAME [-pdVh] [-m MPV_OPTION,...]"
 
 HELP_TEXT="$USAGE
 Get and play music from the Vaporwave Library Project.
@@ -28,12 +31,22 @@ Play music with mpv(1) if none of -pd is specified.
   -p			only print selected URLs to standard output
   -d			donwload selected songs in current working directory
   -m MPV_OPTION,...	pass options to mpv(1)
-  -h			print this extremely helpful text
+  -V			output version information and exit
+  -h			display this extremely helpful text and exit
 
 Exit Status:
   0	if OK,
   1	some errors occurred."
 
+VERSION_INFOTEXT="$PROGRAM_NAME $PROGRAM_VERSION
+git upstream $PROGRAM_UPSTREAM
+Copyright (C) 2020 $AUTHOR_NAME.
+License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
+This is free software: you are free to change and redistribute it.
+There is NO WARRANTY, to the extent permitted by law.
+
+Written by $AUTHOR_NAME."
+
 ###############################################################################
 # USEFUL FUNCTIONS                                                            #
 ###############################################################################
@@ -95,7 +108,7 @@ handle_term()
 # MAIN SECTION                                                                #
 ###############################################################################
 # Parse command line
-while getopts pdm:h f; do
+while getopts pdm:Vh f; do
 	case $f in
 		p)
 			MODE="playlist"
@@ -106,6 +119,9 @@ while getopts pdm:h f; do
 		m)
 			MPV_CMDLINE=$(echo "${OPTARG}" | sed -e 's/[[:space:]]//g' -e 's/[^,]\{2,\}/--& /g' -e 's/\(^\|,\)[[:alnum:]]\($\|,\)/ -& /g' -e 's/,//g')
 		;;
+		V)
+			echo "${VERSION_INFOTEXT}" && exit 0
+		;;
 		h)
 			echo "${HELP_TEXT}" && exit 0
 		;;