forked from iambus/xunlei-lixian
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lixian_cli.py
executable file
·65 lines (58 loc) · 1.76 KB
/
lixian_cli.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python
from lixian_commands.util import *
import lixian_help
import sys
from lixian_commands.login import login
from lixian_commands.logout import logout
from lixian_commands.download import download_task
from lixian_commands.list import list_task
from lixian_commands.add import add_task
from lixian_commands.delete import delete_task
from lixian_commands.pause import pause_task
from lixian_commands.restart import restart_task
from lixian_commands.rename import rename_task
from lixian_commands.readd import readd_task
from lixian_commands.info import lixian_info
from lixian_commands.config import lx_config
from lixian_commands.help import lx_help
def execute_command(args=sys.argv[1:]):
import lixian_plugins # load plugins at import
if not args:
usage()
sys.exit(1)
command = args[0]
if command.startswith('-'):
if command in ('-h', '--help'):
usage(lixian_help.welcome_help)
elif command in ('-v', '--version'):
print '0.0.x'
else:
usage()
sys.exit(1)
sys.exit(0)
import lixian_alias
command = lixian_alias.to_alias(command)
commands = {'login': login,
'logout': logout,
'download': download_task,
'list': list_task,
'add': add_task,
'delete': delete_task,
'pause': pause_task,
'restart': restart_task,
'rename': rename_task,
'readd': readd_task,
'info': lixian_info,
'config': lx_config,
'help': lx_help}
import lixian_plugins.commands
commands.update(lixian_plugins.commands.commands)
if command not in commands:
usage()
sys.exit(1)
if '-h' in args or '--help' in args:
lx_help([command])
else:
commands[command](args[1:])
if __name__ == '__main__':
execute_command()