fix completion of 'cd' after using 'ls' with a parameter
This commit is contained in:
parent
44ca257bae
commit
1833952af1
1 changed files with 25 additions and 21 deletions
|
|
@ -851,17 +851,19 @@ class ReplApplication(Cmd, ConsoleApplication):
|
||||||
|
|
||||||
def do_ls(self, line):
|
def do_ls(self, line):
|
||||||
"""
|
"""
|
||||||
ls
|
ls [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.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# We have an argument, let's ch to the directory before the ls
|
path = line.strip()
|
||||||
if len(line.strip()):
|
|
||||||
self.working_path.cd1(line)
|
|
||||||
|
|
||||||
self.objects, self.collections = self._fetch_objects(objs=self.COLLECTION_OBJECTS)
|
if path:
|
||||||
|
# We have an argument, let's ch to the directory before the ls
|
||||||
|
self.working_path.cd1(path)
|
||||||
|
|
||||||
|
self.objects, collections = self._fetch_objects(objs=self.COLLECTION_OBJECTS)
|
||||||
|
|
||||||
for obj in self.objects:
|
for obj in self.objects:
|
||||||
if isinstance(obj, CapBaseObject):
|
if isinstance(obj, CapBaseObject):
|
||||||
|
|
@ -869,8 +871,7 @@ class ReplApplication(Cmd, ConsoleApplication):
|
||||||
else:
|
else:
|
||||||
print obj
|
print obj
|
||||||
|
|
||||||
if self.collections:
|
for collection in collections:
|
||||||
for collection in self.collections:
|
|
||||||
if collection.basename and collection.title:
|
if collection.basename and collection.title:
|
||||||
print u'%s~ (%s) %s (%s)%s' % \
|
print u'%s~ (%s) %s (%s)%s' % \
|
||||||
(self.BOLD, collection.basename, collection.title, collection.backend, self.NC)
|
(self.BOLD, collection.basename, collection.title, collection.backend, self.NC)
|
||||||
|
|
@ -878,9 +879,12 @@ class ReplApplication(Cmd, ConsoleApplication):
|
||||||
print u'%s~ (%s) (%s)%s' % \
|
print u'%s~ (%s) (%s)%s' % \
|
||||||
(self.BOLD, collection.basename, collection.backend, self.NC)
|
(self.BOLD, collection.basename, collection.backend, self.NC)
|
||||||
|
|
||||||
|
if path:
|
||||||
# Let's go back to the parent directory
|
# Let's go back to the parent directory
|
||||||
if len(line.strip()):
|
|
||||||
self.working_path.home()
|
self.working_path.home()
|
||||||
|
else:
|
||||||
|
# Save collections only if we listed the current path.
|
||||||
|
self.collections = collections
|
||||||
|
|
||||||
def do_cd(self, line):
|
def do_cd(self, line):
|
||||||
"""
|
"""
|
||||||
|
|
@ -899,8 +903,8 @@ class ReplApplication(Cmd, ConsoleApplication):
|
||||||
|
|
||||||
collections = []
|
collections = []
|
||||||
try:
|
try:
|
||||||
for backend, res in self.do('get_collection',
|
for backend, res in self.do('get_collection', objs=self.COLLECTION_OBJECTS,
|
||||||
objs=self.COLLECTION_OBJECTS, split_path=self.working_path.get(),
|
split_path=self.working_path.get(),
|
||||||
caps=ICapCollection):
|
caps=ICapCollection):
|
||||||
if res:
|
if res:
|
||||||
collections.append(res)
|
collections.append(res)
|
||||||
|
|
@ -926,8 +930,8 @@ class ReplApplication(Cmd, ConsoleApplication):
|
||||||
split_path = self.working_path.get()
|
split_path = self.working_path.get()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for backend, res in self.do('iter_resources',
|
for backend, res in self.do('iter_resources', objs=objs,
|
||||||
objs=objs, split_path=split_path,
|
split_path=split_path,
|
||||||
caps=ICapCollection):
|
caps=ICapCollection):
|
||||||
if isinstance(res, Collection):
|
if isinstance(res, Collection):
|
||||||
collections.append(res)
|
collections.append(res)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue