summaryrefslogtreecommitdiff
path: root/trunk/src
diff options
context:
space:
mode:
authorfuzzyray <fuzzyray@gentoo.org>2006-12-12 22:22:44 +0000
committerfuzzyray <fuzzyray@gentoo.org>2006-12-12 22:22:44 +0000
commit4de8b35818cc20a672372a098ae62517bfd4b014 (patch)
tree477153a1d30564da7e431b6b27d786baf0a5ea00 /trunk/src
parent2d1da63195665189c7974e936eb8de3cf5177684 (diff)
downloadgentoolkit-4de8b35818cc20a672372a098ae62517bfd4b014.tar.gz
Add --tree option to equery files command. (Bug #62898)
svn path=/; revision=327
Diffstat (limited to 'trunk/src')
-rwxr-xr-xtrunk/src/equery/equery44
-rw-r--r--trunk/src/equery/equery.13
2 files changed, 41 insertions, 6 deletions
diff --git a/trunk/src/equery/equery b/trunk/src/equery/equery
index 937dd06..50f56f2 100755
--- a/trunk/src/equery/equery
+++ b/trunk/src/equery/equery
@@ -116,6 +116,7 @@ class CmdListFiles(Command):
"showType": 0,
"showTimestamp": 0,
"showMD5": 0,
+ "tree": 0,
"filter": None
}
@@ -132,6 +133,8 @@ class CmdListFiles(Command):
opts["showTimestamp"] = 1
elif x in ["--type"]:
opts["showType"] = 1
+ elif x in ["--tree"]:
+ opts["tree"] = 1
elif x[:9] == "--filter=":
opts["filter"] = string.split(x[9:],',')
elif x[0] == "/":
@@ -223,6 +226,10 @@ class CmdListFiles(Command):
(query, opts) = self.parseArgs(args)
+ # Turn off filtering for tree output
+ if opts["tree"]:
+ opts["filter"] = None
+
if not Config["piping"] and Config["verbosityLevel"] >= 3:
print_info(3, "[ Searching for packages matching " + pp.pkgquery(query) + "... ]")
@@ -239,13 +246,37 @@ class CmdListFiles(Command):
filenames = cnt.keys()
filenames.sort()
+ last=[]
for name in filenames:
- print_info(0, fileAsStr(name,
- cnt[name],
- showType=opts["showType"],
- showTimestamp=opts["showTimestamp"],
- showMD5=opts["showMD5"]))
-
+ if not opts["tree"]:
+ print_info(0, fileAsStr(name,
+ cnt[name],
+ showType=opts["showType"],
+ showTimestamp=opts["showTimestamp"],
+ showMD5=opts["showMD5"]))
+ else:
+ c = name.split( "/" )[1:]
+ if cnt[name][0] == "dir":
+ if len(last) == 0:
+ last = c
+ print pp.path(" /" + c[0])
+ continue
+ numol = 0
+ for d in c:
+ if d in last:
+ numol = last.index(d) + 1
+ continue
+ last = c
+ if len(last) == 1:
+ print pp.path(" " + last[0])
+ continue
+ print pp.path(" " * ( numol * 3 ) + "> " + "/" + last[-1])
+ elif cnt[name][0] == "sym":
+ print pp.path(" " * ( bl * 3 ) + "+ ") + pp.path_symlink(c[-1] + " -> " + cnt[name][2])
+ else:
+ bl = len(last)
+ print pp.path(" " * ( bl * 3 ) + "+ ") + c[-1]
+
def longHelp(self):
return "List files owned by a particular package\n" + \
"\n" + \
@@ -258,6 +289,7 @@ class CmdListFiles(Command):
" " + pp.localoption("--timestamp") + " - append timestamp\n" + \
" " + pp.localoption("--md5sum") + " - append md5sum\n" + \
" " + pp.localoption("--type") + " - prepend file type\n" + \
+ " " + pp.localoption("--tree") + " - display results in a tree (turns off other options)\n" + \
" " + pp.localoption("--filter=<rules>") + " - filter output\n" + \
" " + pp.localoption("<rules>") + " is a comma separated list of elements you want to see:\n" + \
" " + " " + pp.localoption("dir") + \
diff --git a/trunk/src/equery/equery.1 b/trunk/src/equery/equery.1
index 5d4366c..f653825 100644
--- a/trunk/src/equery/equery.1
+++ b/trunk/src/equery/equery.1
@@ -106,6 +106,9 @@ output the md5sum of each file
.B \-\-type
output the type of each file
.br
+.B \-\-tree
+display results in a tree (turns off all other options)
+.br
.B \-\-filter=<rules>
filter output based on files type or path
.br