diff options
author | Doug Anderson <dianders@google.com> | 2011-03-14 16:07:42 -0700 |
---|---|---|
committer | Doug Anderson <dianders@google.com> | 2011-03-16 12:55:44 -0700 |
commit | fce89f218a57e651e18cb91f5154e226c3f152b5 (patch) | |
tree | 87283ea19114b10352514ebd4e025b1e8f603f8a | |
parent | 37282b4b9c5b1d9a1ff07f7f0686a81b65a0a5c6 (diff) | |
download | git-repo-fce89f218a57e651e18cb91f5154e226c3f152b5.tar.gz |
Add 'list' command to repo.
This isn't a required command, but might be more discoverable for
repo newbies?
Change-Id: If357346f234774d42e04e024e65acdaf6dca6c62
-rw-r--r-- | subcmds/list.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/subcmds/list.py b/subcmds/list.py new file mode 100644 index 00000000..2be82570 --- /dev/null +++ b/subcmds/list.py | |||
@@ -0,0 +1,48 @@ | |||
1 | # | ||
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 | |||
16 | from command import Command, MirrorSafeCommand | ||
17 | |||
18 | class List(Command, MirrorSafeCommand): | ||
19 | common = True | ||
20 | helpSummary = "List projects and their associated directories" | ||
21 | helpUsage = """ | ||
22 | %prog [<project>...] | ||
23 | """ | ||
24 | helpDescription = """ | ||
25 | List all projects; pass '.' to list the project for the cwd. | ||
26 | |||
27 | This 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) | ||