Package zeroinstall :: Package cmd :: Module add
[frames] | no frames]

Source Code for Module zeroinstall.cmd.add

 1  """ 
 2  The B{0install add} command-line interface. 
 3  """ 
 4   
 5  # Copyright (C) 2012, Thomas Leonard 
 6  # See the README file for details, or visit http://0install.net. 
 7   
 8  from __future__ import print_function 
 9   
10  import sys 
11   
12  from zeroinstall import _ 
13  from zeroinstall.cmd import UsageError, select 
14  from zeroinstall.injector import model, requirements 
15   
16  syntax = "PET-NAME INTERFACE" 
17   
18 -def add_options(parser):
19 select.add_options(parser)
20
21 -def handle(config, options, args):
22 """@type args: [str]""" 23 if len(args) != 2: 24 raise UsageError() 25 26 pet_name = args[0] 27 iface_uri = model.canonical_iface_uri(args[1]) 28 29 sels = select.get_selections(config, options, iface_uri, select_only = False, download_only = True, test_callback = None) 30 if not sels: 31 sys.exit(1) # Aborted by user 32 33 root_feed = config.iface_cache.get_feed(iface_uri) 34 if root_feed: 35 target = root_feed.get_replaced_by() 36 if target is not None: 37 print(_("Warning: interface {old} has been replaced by {new}".format(old = iface_uri, new = target))) 38 39 r = requirements.Requirements(iface_uri) 40 r.parse_options(options) 41 42 app = config.app_mgr.create_app(pet_name, r) 43 app.set_selections(sels) 44 app.integrate_shell(pet_name)
45
46 -def complete(completion, args, cword):
47 """@type completion: L{zeroinstall.cmd._Completion} 48 @type args: [str] 49 @type cword: int""" 50 if cword != 1: return 51 completion.expand_interfaces()
52