Added help.
[zeroinstall/solver.git] / injector
blob65659936204d821e66791a7fd3030f70dda6b3af
1 #!/usr/bin/env python
2 import sys, os
3 from xml.dom import minidom
5 from interface import get_interface
6 import run
8 if len(sys.argv) < 3:
9 print "Usage: injector PROG INTERFACE [ARGS]"
10 print "PROG is a relative path inside an implementation of INTERFACE. Eg:"
11 print "injector bin/myprog /uri/0install/site/myprog.xml --help"
12 sys.exit(1)
13 prog = sys.argv[1]
14 interface = sys.argv[2]
15 prog_args = sys.argv[3:]
16 interactive = bool(os.environ.get('INJECTOR_INTERACTIVE', None))
18 interface = os.path.abspath(interface)
20 if not interface.startswith('/'):
21 print "Interface must be an absolute pathname (starting with /)"
22 sys.exit(1)
24 if not os.path.exists(interface):
25 print "Interface file '%s' not found" % interface
26 sys.exit(1)
28 #print "Looking for an implementation of", interface
30 iface = get_interface(interface)
32 if interactive:
33 import gui
34 policy = gui.InteractivePolicy()
35 else:
36 from policy import Policy
37 policy = Policy()
39 selection = policy.choose_best(iface)
41 run.execute(selection, iface, prog, prog_args)