2 The B{0install run} command-line interface.
5 # Copyright (C) 2011, Thomas Leonard
6 # See the README file for details, or visit http://0install.net.
8 from optparse
import OptionParser
12 from zeroinstall
import cmd
, SafeException
, _
13 from zeroinstall
.cmd
import UsageError
, select
14 from zeroinstall
.injector
import model
, autopolicy
, selections
, handler
15 from zeroinstall
.injector
.iface_cache
import iface_cache
19 def add_options(parser
):
20 select
.add_generic_select_options(parser
)
21 parser
.add_option("-m", "--main", help=_("name of the file to execute"))
22 parser
.add_option("-w", "--wrapper", help=_("execute program using a debugger, etc"), metavar
='COMMAND')
23 parser
.disable_interspersed_args()
25 def handle(options
, args
):
28 iface_uri
= model
.canonical_iface_uri(args
[0])
31 def test_callback(sels
):
32 from zeroinstall
.injector
import run
33 return run
.test_selections(sels
, prog_args
,
37 sels
= select
.get_selections(options
, iface_uri
,
38 select_only
= False, download_only
= False,
39 test_callback
= test_callback
)
41 sys
.exit(1) # Aborted by user
43 from zeroinstall
.injector
import run
44 run
.execute_selections(sels
, prog_args
, main
= options
.main
, wrapper
= options
.wrapper
)