Added "0install download"
[zeroinstall/zeroinstall-limyreth.git] / zeroinstall / cmd / download.py
blobd60eeb5e8a1d5113a98f66325fb1c99ceca48eae
1 """
2 The B{0install download} command-line interface.
3 """
5 # Copyright (C) 2011, Thomas Leonard
6 # See the README file for details, or visit http://0install.net.
8 from optparse import OptionParser
9 import os, sys
10 import logging
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
17 syntax = "URI"
19 def add_options(parser):
20 select.add_options(parser)
21 parser.add_option("", "--show", help=_("show where components are installed"), action='store_true')
23 def handle(options, args):
24 if len(args) != 1:
25 raise UsageError()
26 uri = args[0]
27 iface_uri = model.canonical_iface_uri(args[0])
29 sels = select.get_selections(options, iface_uri,
30 select_only = False, download_only = True, test_callback = None)
31 if not sels:
32 sys.exit(1) # Aborted by user
34 if options.xml:
35 select.show_xml(sels)
36 if options.show:
37 select.show_human(sels)