mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-04-30 01:03:14 +02:00
Ensure output of calibredb list is always sorted
This commit is contained in:
parent
f785c132ad
commit
0ebb813f8b
1 changed files with 4 additions and 3 deletions
|
|
@ -70,8 +70,9 @@ def get_db(dbpath, options):
|
|||
def do_list(db, fields, afields, sort_by, ascending, search_text, line_width, separator,
|
||||
prefix, limit, for_machine=False):
|
||||
from calibre.utils.terminal import ColoredStream, geometry
|
||||
if sort_by:
|
||||
db.sort(sort_by, ascending)
|
||||
if sort_by is None:
|
||||
ascending = True
|
||||
db.sort(sort_by or 'id', ascending)
|
||||
if search_text:
|
||||
db.search(search_text)
|
||||
data = db.get_data_as_dict(prefix, authors_as_string=True, convert_to_local_tz=False)
|
||||
|
|
@ -192,7 +193,7 @@ def list_option_parser(db=None):
|
|||
' special field "all" can be used to select all fields.'
|
||||
)%', '.join(sorted(fields)))
|
||||
parser.add_option('--sort-by', default=None,
|
||||
help=_('The field by which to sort the results.\nAvailable fields: %s\nDefault: %%default')%', '.join(sorted(FIELDS)))
|
||||
help=_('The field by which to sort the results.\nAvailable fields: {0}\nDefault: {1}').format(', '.join(sorted(FIELDS)), 'id'))
|
||||
parser.add_option('--ascending', default=False, action='store_true',
|
||||
help=_('Sort results in ascending order'))
|
||||
parser.add_option('-s', '--search', default=None,
|
||||
|
|
|
|||
Loading…
Reference in a new issue