blob: 2be82570b8deaae0fd6f46e26d7e3473544db45c [file] [log] [blame]
Doug Andersonfce89f22011-03-14 16:07:42 -07001#
2# Copyright (C) 2011 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16from command import Command, MirrorSafeCommand
17
18class List(Command, MirrorSafeCommand):
19 common = True
20 helpSummary = "List projects and their associated directories"
21 helpUsage = """
22%prog [<project>...]
23"""
24 helpDescription = """
25List all projects; pass '.' to list the project for the cwd.
26
27This is similar to running: repo forall -c 'echo "$REPO_PATH : $REPO_PROJECT"'.
28"""
29
30 def Execute(self, opt, args):
31 """List all projects and the associated directories.
32
33 This may be possible to do with 'repo forall', but repo newbies have
34 trouble figuring that out. The idea here is that it should be more
35 discoverable.
36
37 Args:
38 opt: The options. We don't take any.
39 args: Positional args. Can be a list of projects to list, or empty.
40 """
41 projects = self.GetProjects(args)
42
43 lines = []
44 for project in projects:
45 lines.append("%s : %s" % (project.relpath, project.name))
46
47 lines.sort()
48 print '\n'.join(lines)