mirror of
https://github.com/cooperhammond/irs.git
synced 2025-03-22 16:15:05 +00:00
Added a version argument and slightly updated the README
This commit is contained in:
parent
70b3c8447b
commit
e745f086ce
|
@ -20,7 +20,7 @@ optional arguments:
|
|||
```
|
||||
[](https://asciinema.org/a/bcs7i0sjmka052wsdyxg5xrug?speed=3&autoplay=true)
|
||||
|
||||
[](https://asciinema.org/a/8kb9882j4cbtd4hwbsbb7h0ia?speed=3&autoplay=true)
|
||||
[](https://asciinema.org/a/8kb9882j4cbtd4hwbsbb7h0ia?speed=3)
|
||||
|
||||
___
|
||||
### Installation
|
||||
|
|
|
@ -32,6 +32,7 @@ def console():
|
|||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-a', '--artist', dest="artist", help="Specify the artist name")
|
||||
parser.add_argument('-v', '--version', dest="version", action='store_true', help="Display the version and exit.")
|
||||
|
||||
media = parser.add_mutually_exclusive_group()
|
||||
media.add_argument('-A', '--album', dest="album", help="Specify album name of the artist")
|
||||
|
@ -39,6 +40,17 @@ def main():
|
|||
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
if args.version:
|
||||
import pkg_resources
|
||||
print ("\n\n" + color("Ingenious Redistribution System", ["HEADER", "BOLD"]))
|
||||
print ("Homepage: " + color("https://github.com/kepoorhampond/irs", ["OKGREEN"]))
|
||||
print ("License: " + color("The GNU", ["YELLOW"]) + " (http://www.gnu.org/licenses/gpl.html)")
|
||||
print ("Version: " + pkg_resources.get_distribution("irs").version)
|
||||
|
||||
print ("\n")
|
||||
exit(0)
|
||||
|
||||
if args.artist and not (args.album or args.song):
|
||||
print ("usage: __init__.py [-h] [-a ARTIST] [-A ALBUM | -s SONG] \n\
|
||||
error: must specify -A/--album or -s/--song if specifying -a/--artist")
|
||||
|
|
51
irs/utils.py
51
irs/utils.py
|
@ -4,21 +4,48 @@ def strip_special_chars(string):
|
|||
string.replace(char, "")
|
||||
return string
|
||||
|
||||
class bc:
|
||||
HEADER = '\033[95m'
|
||||
OKBLUE = '\033[94m'
|
||||
OKGREEN = '\033[32m'
|
||||
WARNING = '\033[93m'
|
||||
FAIL = '\033[91m'
|
||||
ENDC = '\033[0m'
|
||||
BOLD = '\033[1m'
|
||||
UNDERLINE = '\033[4m'
|
||||
GRAY = '\033[30m'
|
||||
YELLOW = '\033[33m'
|
||||
def supports_color():
|
||||
"""
|
||||
Returns True if the running system's terminal supports color, and False
|
||||
otherwise.
|
||||
"""
|
||||
plat = sys.platform
|
||||
supported_platform = plat != 'Pocket PC' and (plat != 'win32' or
|
||||
'ANSICON' in os.environ)
|
||||
# isatty is not always implemented, #6223.
|
||||
is_a_tty = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty()
|
||||
if not supported_platform or not is_a_tty:
|
||||
return False
|
||||
return True
|
||||
|
||||
if supports_color():
|
||||
class bc:
|
||||
HEADER = '\033[95m'
|
||||
OKBLUE = '\033[94m'
|
||||
OKGREEN = '\033[32m'
|
||||
WARNING = '\033[93m'
|
||||
FAIL = '\033[91m'
|
||||
ENDC = '\033[0m'
|
||||
BOLD = '\033[1m'
|
||||
UNDERLINE = '\033[4m'
|
||||
GRAY = '\033[30m'
|
||||
YELLOW = '\033[33m'
|
||||
else:
|
||||
class bc:
|
||||
HEADER = ''
|
||||
OKBLUE = ''
|
||||
OKGREEN = ''
|
||||
WARNING = ''
|
||||
FAIL = ''
|
||||
ENDC = ''
|
||||
BOLD = ''
|
||||
UNDERLINE = ''
|
||||
GRAY = ''
|
||||
YELLOW = ''
|
||||
|
||||
def color(text, colors=[]):
|
||||
color_string = ""
|
||||
for color in colors:
|
||||
color_string += "bc.%s + " % color
|
||||
color_string = color_string[:-2]
|
||||
return (eval(color_string) + text + bc.ENDC)
|
||||
return (bc.ENDC + eval(color_string) + text + bc.ENDC)
|
||||
|
|
Loading…
Reference in a new issue