aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2021-08-01 11:18:15 -0400
committerDavid Bremner <david@tethera.net>2021-08-01 11:18:15 -0400
commit605264c0f7fc853dc7f5dadd674bf4be954ffdbb (patch)
tree727c1ec6f42716a57254275e0965fc0bee8abe75
parentbb6dd424c819102e7220b82d41d9dfcf939780a8 (diff)
migrate from cmd to cmd2
It fixes an annoying quirk in the command completion that does not leave a space.
-rw-r--r--mm3mod/__init__.py23
-rw-r--r--setup.cfg2
2 files changed, 6 insertions, 19 deletions
diff --git a/mm3mod/__init__.py b/mm3mod/__init__.py
index 92be097..3f22b6d 100644
--- a/mm3mod/__init__.py
+++ b/mm3mod/__init__.py
@@ -2,22 +2,19 @@
# Licensed under the LGPL v3 https://www.gnu.org/licenses/lgpl-3.0.html
import os
-import cmd
+import cmd2
import configparser
from pathlib import PurePath
from mailmanclient.client import Client
-class ModShell(cmd.Cmd):
+class ModShell(cmd2.Cmd):
intro = 'Type help or ? for a list of commands'
def __init__(self, client, mlist):
self.client = client;
self.mlist = mlist;
self.prompt = '({:s}) '.format(mlist.list_name)
- cmd.Cmd.__init__(self)
-
- def emptyline(self):
- pass
+ cmd2.Cmd.__init__(self)
def print_held(self):
self.held_messages = self.mlist.get_held_page (50,1)
@@ -32,7 +29,7 @@ class ModShell(cmd.Cmd):
for msg in self.held_messages:
string = str(msg.request_id)
- if text == string[0:prefix_len]:
+ if string.startswith(text):
candidates.append(string)
return candidates
@@ -55,7 +52,7 @@ class ModShell(cmd.Cmd):
def complete_discard(self, text, line, begidx, endidx):
candidates = self.matching_request_ids(text)
- if text == "page"[0:prefix_len]:
+ if "page".startswith(text):
candidates.append('page')
return candidates
@@ -85,16 +82,6 @@ class ModShell(cmd.Cmd):
self.print_held()
return stop
- def do_EOF(self,arg):
- 'exit'
- return True
-
- def do_quit(self,arg):
- '''
- exit moderation shell
- '''
- return True
-
def main ():
home = os.environ.get('HOME')
diff --git a/setup.cfg b/setup.cfg
index 5460c19..be1d252 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -6,7 +6,7 @@ version = 0.0.1
packages = mm3mod
install_requires =
mailmanclient >= 3.2
-
+ cmd2 >= 0.8.5
[options.entry_points]
console_scripts =