Commit 01619428 authored by Michael Mayr's avatar Michael Mayr

Improved CLI handling

parent c9355432
...@@ -169,17 +169,25 @@ class OldServerVersion(Exception): ...@@ -169,17 +169,25 @@ class OldServerVersion(Exception):
pass pass
def main(): def main():
vlc = VLCClient("ubuntu.local") """Run any commands via CLI interface"""
vlc.connect()
print "Connected to VLC {0}".format(vlc.server_version)
try: try:
command = getattr(vlc, sys.argv[1]) server = sys.argv[1]
if ':' in server:
server, port = server.split(':')
else:
port = 4212
command_name = sys.argv[2]
except IndexError: except IndexError:
print "usage: vlcclient.py command [argument]" print "usage: vlcclient.py server[:port] command [argument]"
sys.exit(1) sys.exit(1)
vlc = VLCClient(server, int(port))
vlc.connect()
print "Connected to VLC {0}".format(vlc.server_version)
try: try:
command = getattr(vlc, command_name)
attr = sys.argv[2] if len(sys.argv) > 2 else None attr = sys.argv[2] if len(sys.argv) > 2 else None
try: try:
print command(attr) print command(attr)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment