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.
10 from zeroinstall
import _
11 from zeroinstall
.support
import tasks
12 from zeroinstall
.cmd
import UsageError
, select
13 from zeroinstall
.injector
import model
17 def add_options(parser
):
18 select
.add_generic_select_options(parser
)
19 parser
.add_option("-m", "--main", help=_("name of the file to execute"))
20 parser
.add_option("-w", "--wrapper", help=_("execute program using a debugger, etc"), metavar
='COMMAND')
21 parser
.disable_interspersed_args()
23 def handle(config
, options
, args
):
29 def test_callback(sels
):
30 from zeroinstall
.injector
import run
31 return run
.test_selections(sels
, prog_args
,
35 app
= config
.app_mgr
.lookup_app(args
[0], missing_ok
= True)
37 sels
= app
.get_selections()
38 r
= app
.get_requirements()
39 do_select
= r
.parse_update_options(options
)
40 iface_uri
= sels
.interface
42 iface_uri
= model
.canonical_iface_uri(args
[0])
45 if do_select
or options
.gui
:
46 sels
= select
.get_selections(config
, options
, iface_uri
,
47 select_only
= False, download_only
= False,
48 test_callback
= test_callback
)
50 sys
.exit(1) # Aborted by user
52 dl
= app
.download_selections(sels
)
54 tasks
.wait_for_blocker(dl
)
57 from zeroinstall
.injector
import run
58 run
.execute_selections(sels
, prog_args
, dry_run
= options
.dry_run
, main
= options
.main
, wrapper
= options
.wrapper
, stores
= config
.stores
)