diff options
author | Anton Khirnov <anton@khirnov.net> | 2021-01-31 09:51:36 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2021-01-31 09:51:36 +0100 |
commit | c83da858d191c663894bef6d192d9bb489b082f5 (patch) | |
tree | ae86ac2856d560c0a7c1c44acdf0c7249e8bb975 /alot/commands | |
parent | cf6d0be6502b790f91c7f4e0f1738ef8381fab70 (diff) |
db: use symbolic constants for sort orders
Diffstat (limited to 'alot/commands')
-rw-r--r-- | alot/commands/globals.py | 6 | ||||
-rw-r--r-- | alot/commands/search.py | 7 |
2 files changed, 7 insertions, 6 deletions
diff --git a/alot/commands/globals.py b/alot/commands/globals.py index 6c73e6c9..5304b32d 100644 --- a/alot/commands/globals.py +++ b/alot/commands/globals.py @@ -28,6 +28,7 @@ from ..completion.commandline import CommandLineCompleter from ..completion.contacts import ContactsCompleter from ..completion.accounts import AccountCompleter from ..completion.tags import TagsCompleter +from ..db.sort import NAME as SORT_NAME from ..widgets.utils import DialogBox from ..mail.envelope import Envelope from ..settings.const import settings @@ -77,8 +78,7 @@ class ExitCommand(Command): ui.exit() @registerCommand(MODE, 'search', usage='search query', arguments=[ - (['--sort'], {'help': 'sort order', 'choices': [ - 'oldest_first', 'newest_first', 'message_id', 'unsorted']}), + (['--sort'], {'help': 'sort order', 'choices': list(SORT_NAME.keys())}), (['query'], {'nargs': argparse.REMAINDER, 'help': 'search string'})]) class SearchCommand(Command): @@ -96,7 +96,7 @@ class SearchCommand(Command): :type sort: str """ self.query = ' '.join(query) - self.order = sort + self.order = SORT_NAME[sort] if sort else None super().__init__(**kwargs) def apply(self, ui): diff --git a/alot/commands/search.py b/alot/commands/search.py index 14f267cd..82a3cf39 100644 --- a/alot/commands/search.py +++ b/alot/commands/search.py @@ -13,6 +13,7 @@ from .. import commands from .. import buffers from ..db.errors import DatabaseROError +from ..db.sort import NAME as SORT_NAME MODE = 'search' @@ -35,8 +36,8 @@ class OpenThreadCommand(Command): @registerCommand(MODE, 'refine', help='refine query', arguments=[ - (['--sort'], {'help': 'sort order', 'choices': [ - 'oldest_first', 'newest_first', 'message_id', 'unsorted']}), + (['--sort'], {'help': 'sort order', + 'choices': list(SORT_NAME.keys())}), (['query'], {'nargs': argparse.REMAINDER, 'help': 'search string'})]) @registerCommand(MODE, 'sort', help='set sort order', arguments=[ (['sort'], {'help': 'sort order', 'choices': [ @@ -55,7 +56,7 @@ class RefineCommand(Command): self.querystring = None else: self.querystring = ' '.join(query) - self.sort_order = sort + self.sort_order = SORT_NAME[sort] super().__init__(**kwargs) def apply(self, ui): |