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
18 def add_options(parser
):
19 select
.add_generic_select_options(parser
)
20 parser
.add_option("-m", "--main", help=_("name of the file to execute"))
21 parser
.add_option("-w", "--wrapper", help=_("execute program using a debugger, etc"), metavar
='COMMAND')
22 parser
.disable_interspersed_args()
24 def handle(config
, options
, args
):
27 iface_uri
= model
.canonical_iface_uri(args
[0])
30 def test_callback(sels
):
31 from zeroinstall
.injector
import run
32 return run
.test_selections(sels
, prog_args
,
36 sels
= select
.get_selections(config
, options
, iface_uri
,
37 select_only
= False, download_only
= False,
38 test_callback
= test_callback
)
40 sys
.exit(1) # Aborted by user
42 from zeroinstall
.injector
import run
43 run
.execute_selections(sels
, prog_args
, dry_run
= options
.dry_run
, main
= options
.main
, wrapper
= options
.wrapper
, stores
= config
.stores
)