10 | def get_args(): |
11 | argv = sys.argv |
12 | if len(argv) > 3 or len(argv) <= 1: |
13 | print 'error: too many or too few options!' |
14 | print 'usage: %s %s' % (argv[0], ' install|uninstall [--prefix=INSTALL_PATH]') |
15 | sys.exit(0) |
16 | |
17 | action = '' |
18 | install_root = '' |
19 | |
20 | for arg in argv[1:]: |
21 | if arg == 'install': |
22 | action = 'install' |
23 | elif arg == 'uninstall': |
24 | action = 'uninstall' |
25 | elif arg.find('--prefix=') == 0: |
26 | install_root = os.path.expanduser(arg[arg.rindex('=')+1:]) + '/buildc' |
27 | else: |
28 | print 'error: unsupport option: %s' % arg |
29 | print 'usage: %s %s' % (argv[0], ' install|uninstall [--prefix=INSTALL_PATH]') |
30 | |
31 | if action == '': |
32 | print 'usage: %s %s' % (argv[0], ' install|uninstall [--prefix=INSTALL_PATH]') |
33 | |
34 | if install_root == '': |
35 | install_root = DEFAULT_INSTALL_ROOT |
36 | |
37 | return action, install_root |