Added '0install list' sub-command
[zeroinstall/zeroinstall-afb.git] / zeroinstall / cmd / list.py
blob2bfd3d96e03b30f7ee352cb77033a9de4e7f6a0b
1 """
2 The B{0install list} command-line interface.
3 """
5 # Copyright (C) 2011, Thomas Leonard
6 # See the README file for details, or visit http://0install.net.
8 from zeroinstall.cmd import UsageError
9 from zeroinstall.injector.iface_cache import iface_cache
11 syntax = "PATTERN"
13 def add_options(parser):
14 pass
16 def handle(options, args):
17 if len(args) == 0:
18 matches = iface_cache.list_all_interfaces()
19 elif len(args) == 1:
20 match = args[0].lower()
21 matches = [i for i in iface_cache.list_all_interfaces() if match in i.lower()]
22 else:
23 raise UsageError()
25 matches.sort()
26 for i in matches:
27 print i