Add support for ls -d option (closes #858)
This behaves like the UNIX ls -d. This should solve the use case of Bug #858; ls was never intended to work that way before. Users can now chose between the two modes (with or without -d).
This commit is contained in:
parent
abe3f3c4a0
commit
4d1e6f8436
1 changed files with 19 additions and 13 deletions
|
|
@ -916,13 +916,17 @@ class ReplApplication(Cmd, ConsoleApplication):
|
||||||
|
|
||||||
def do_ls(self, line):
|
def do_ls(self, line):
|
||||||
"""
|
"""
|
||||||
ls [PATH]
|
ls [-d] [PATH]
|
||||||
|
|
||||||
List objects in current path.
|
List objects in current path.
|
||||||
If an argument is given, list the specified path.
|
If an argument is given, list the specified path.
|
||||||
"""
|
"""
|
||||||
|
if line.strip().partition(' ')[0] == '-d':
|
||||||
path = line.strip()
|
path = None
|
||||||
|
only = line.strip().partition(' ')[2]
|
||||||
|
else:
|
||||||
|
path = line.strip()
|
||||||
|
only = False
|
||||||
|
|
||||||
if path:
|
if path:
|
||||||
# We have an argument, let's ch to the directory before the ls
|
# We have an argument, let's ch to the directory before the ls
|
||||||
|
|
@ -933,18 +937,20 @@ class ReplApplication(Cmd, ConsoleApplication):
|
||||||
self.start_format()
|
self.start_format()
|
||||||
self.objects = []
|
self.objects = []
|
||||||
for obj in objects:
|
for obj in objects:
|
||||||
if isinstance(obj, CapBaseObject):
|
if only is False or not hasattr(obj, 'id') or obj.id in only:
|
||||||
self.cached_format(obj)
|
if isinstance(obj, CapBaseObject):
|
||||||
else:
|
self.cached_format(obj)
|
||||||
print obj
|
else:
|
||||||
|
print obj
|
||||||
|
|
||||||
for collection in collections:
|
for collection in collections:
|
||||||
if collection.basename and collection.title:
|
if only is False or collection.basename in only:
|
||||||
print u'%s~ (%s) %s (%s)%s' % \
|
if collection.basename and collection.title:
|
||||||
(self.BOLD, collection.basename, collection.title, collection.backend, self.NC)
|
print u'%s~ (%s) %s (%s)%s' % \
|
||||||
else:
|
(self.BOLD, collection.basename, collection.title, collection.backend, self.NC)
|
||||||
print u'%s~ (%s) (%s)%s' % \
|
else:
|
||||||
(self.BOLD, collection.basename, collection.backend, self.NC)
|
print u'%s~ (%s) (%s)%s' % \
|
||||||
|
(self.BOLD, collection.basename, collection.backend, self.NC)
|
||||||
|
|
||||||
if path:
|
if path:
|
||||||
# Let's go back to the parent directory
|
# Let's go back to the parent directory
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue