Commit 4bcc0090 authored by Mark Sapiro's avatar Mark Sapiro Committed by Abhilash Raj

Add deprecation notes to the help for members add, delete and sync options.

parent 359a0595
......@@ -262,14 +262,16 @@ def sync_members(mlist, sync_infp, no_change):
help=_("""\
[MODE] Add all member addresses in FILENAME. FILENAME can be '-' to
indicate standard input. Blank lines and lines that start with a
'#' are ignored."""))
'#' are ignored. This option is deprecated in favor of 'mailman
addmembers'."""))
@click.option(
'--delete', '-x', 'del_infp', metavar='FILENAME',
type=click.File(encoding='utf-8'),
help=_("""\
[MODE] Delete all member addresses found in FILENAME
from the specified list. FILENAME can be '-' to indicate standard input.
Blank lines and lines that start with a '#' are ignored."""))
Blank lines and lines that start with a '#' are ignored.
This option is deprecated in favor of 'mailman delmembers'."""))
@click.option(
'--sync', '-s', 'sync_infp', metavar='FILENAME',
type=click.File(encoding='utf-8'),
......@@ -277,7 +279,8 @@ def sync_members(mlist, sync_infp, no_change):
[MODE] Synchronize all member addresses of the specified mailing list
with the member addresses found in FILENAME.
FILENAME can be '-' to indicate standard input.
Blank lines and lines that start with a '#' are ignored."""))
Blank lines and lines that start with a '#' are ignored.
This option is deprecated in favor of 'mailman syncmembers'."""))
@click.option(
'--output', '-o', 'outfp', metavar='FILENAME',
type=click.File(mode='w', encoding='utf-8', atomic=True),
......@@ -339,10 +342,16 @@ def members(ctx, add_infp, del_infp, sync_infp, outfp,
if mlist is None:
ctx.fail(_('No such list: $listspec'))
if add_infp is not None:
print('Warning: The --add option is deprecated. '
'Use `mailman addmembers` instead.', file=sys.stderr)
add_members(mlist, add_infp)
elif del_infp is not None:
print('Warning: The --delete option is deprecated. '
'Use `mailman delmembers` instead.', file=sys.stderr)
delete_members(mlist, del_infp)
elif sync_infp is not None:
print('Warning: The --sync option is deprecated. '
'Use `mailman syncmembers` instead.', file=sys.stderr)
sync_members(mlist, sync_infp, no_change)
else:
display_members(ctx, mlist, role, regular,
......
......@@ -176,6 +176,7 @@ need a file containing email addresses and full names that can be parsed by
... """, file=fp)
>>> command('mailman members --add ' + filename + ' bee.example.com')
Warning: The --add option is deprecated. Use `mailman addmembers` instead.
>>> from operator import attrgetter
>>> dump_list(bee.members.addresses, key=attrgetter('email'))
......@@ -193,6 +194,7 @@ taken from standard input.
... [email protected] (Fred Person)
... """
>>> command('mailman members --add - bee.example.com', input=stdin)
Warning: The --add option is deprecated. Use `mailman addmembers` instead.
>>> dump_list(bee.members.addresses, key=attrgetter('email'))
[email protected]
......@@ -214,6 +216,7 @@ Blank lines and lines that begin with '#' are ignored.
... """, file=fp)
>>> command('mailman members --add ' + filename + ' bee.example.com')
Warning: The --add option is deprecated. Use `mailman addmembers` instead.
>>> dump_list(bee.members.addresses, key=attrgetter('email'))
[email protected]
......@@ -237,6 +240,7 @@ printed.
... """, file=fp)
>>> command('mailman members --add ' + filename + ' bee.example.com')
Warning: The --add option is deprecated. Use `mailman addmembers` instead.
Already subscribed (skipping): [email protected]
Already subscribed (skipping): [email protected]
......@@ -271,6 +275,7 @@ use these code snippets to delete subscriptions from the list again.
... """, file=fp)
>>> command('mailman members --delete ' + filename + ' bee.example.com')
Warning: The --delete option is deprecated. Use `mailman delmembers` instead.
>>> from operator import attrgetter
>>> dump_list(bee.members.addresses, key=attrgetter('email'))
......@@ -291,6 +296,7 @@ taken from standard input.
... Elly Person <[email protected]>
... """
>>> command('mailman members --delete - bee.example.com', input=stdin)
Warning: The --delete option is deprecated. Use `mailman delmembers` instead.
>>> dump_list(bee.members.addresses, key=attrgetter('email'))
Bart Person <[email protected]>
......@@ -310,6 +316,7 @@ Blank lines and lines that begin with '#' are ignored.
... """, file=fp)
>>> command('mailman members --delete ' + filename + ' bee.example.com')
Warning: The --delete option is deprecated. Use `mailman delmembers` instead.
>>> dump_list(bee.members.addresses, key=attrgetter('email'))
Fred Person <[email protected]>
......@@ -328,6 +335,7 @@ printed.
... """, file=fp)
>>> command('mailman members --delete ' + filename + ' bee.example.com')
Warning: The --delete option is deprecated. Use `mailman delmembers` instead.
Member not subscribed (skipping): kperson[email protected]
>>> dump_list(bee.members.addresses, key=attrgetter('email'))
......@@ -360,6 +368,7 @@ written to output.
... """, file=fp)
>>> command('mailman members --sync ' + filename + ' bee.example.com')
Warning: The --sync option is deprecated. Use `mailman syncmembers` instead.
[ADD] [email protected]
[ADD] Cate Person <[email protected]>
[DEL] [email protected]
......@@ -380,6 +389,7 @@ taken from standard input.
... Elly Person <[email protected]>
... """
>>> command('mailman members --sync - bee.example.com', input=stdin)
Warning: The --sync option is deprecated. Use `mailman syncmembers` instead.
[ADD] [email protected]
[ADD] Elly Person <[email protected]>
[DEL] [email protected]
......@@ -402,6 +412,7 @@ Blank lines and lines that begin with '#' are ignored.
... """, file=fp)
>>> command('mailman members --sync ' + filename + ' bee.example.com')
Warning: The --sync option is deprecated. Use `mailman syncmembers` instead.
[ADD] [email protected]
[DEL] [email protected]
......@@ -419,6 +430,7 @@ If there is nothing to do, it will output just that.
... """, file=fp)
>>> command('mailman members --sync ' + filename + ' bee.example.com')
Warning: The --sync option is deprecated. Use `mailman syncmembers` instead.
Nothing to do
>>> dump_list(bee.members.addresses, key=attrgetter('email'))
......
......@@ -109,6 +109,8 @@ class TestCLIMembers(unittest.TestCase):
'--add', infp.name, 'ant.example.com'))
self.assertEqual(
result.output,
'Warning: The --add option is deprecated. Use '
'`mailman addmembers` instead.\n'
'Already subscribed (skipping): Anne Person <[email protected]>\n'
)
......@@ -119,6 +121,8 @@ class TestCLIMembers(unittest.TestCase):
'--add', infp.name, 'ant.example.com'))
self.assertEqual(
result.output,
'Warning: The --add option is deprecated. Use '
'`mailman addmembers` instead.\n'
'Cannot parse as valid email address (skipping): [email protected]\n'
)
......@@ -129,7 +133,9 @@ class TestCLIMembers(unittest.TestCase):
'--delete', infp.name, 'ant.example.com'))
self.assertEqual(
result.output,
'Member not subscribed (skipping): ' +
'Warning: The --delete option is deprecated. Use '
'`mailman delmembers` instead.\n'
'Member not subscribed (skipping): '
'[email protected]\n'
)
......@@ -140,7 +146,9 @@ class TestCLIMembers(unittest.TestCase):
'--delete', infp.name, 'ant.example.com'))
self.assertEqual(
result.output,
'Member not subscribed (skipping): ' +
'Warning: The --delete option is deprecated. Use '
'`mailman delmembers` instead.\n'
'Member not subscribed (skipping): '
'Anne Person <[email protected]>\n'
)
......@@ -156,8 +164,10 @@ class TestCLIMembers(unittest.TestCase):
print('Bart Person <[email protected]>', file=infp)
result = self._command.invoke(members, (
'--delete', infp.name, 'ant.example.com'))
self.assertEqual(result.output, "")
self.assertEqual(
result.output,
'Warning: The --delete option is deprecated. Use '
'`mailman delmembers` instead.\n')
with NamedTemporaryFile('w', encoding='utf-8') as outfp:
self._command.invoke(members, (
'-o', outfp.name, 'ant.example.com'))
......@@ -174,7 +184,10 @@ class TestCLIMembers(unittest.TestCase):
print('#Bart Person <[email protected]>', file=infp)
result = self._command.invoke(members, (
'--delete', infp.name, 'ant.example.com'))
self.assertEqual(result.output, "")
self.assertEqual(
result.output,
'Warning: The --delete option is deprecated. Use '
'`mailman delmembers` instead.\n')
with NamedTemporaryFile('w', encoding='utf-8') as outfp:
self._command.invoke(members, (
......@@ -191,12 +204,14 @@ class TestCLIMembers(unittest.TestCase):
result = self._command.invoke(members, (
'--sync', infp.name, 'ant.example.com'))
self.assertEqual(
result.output,
'Cannot parse as valid email address' +
' (skipping): Dont Subscribe <not-a-valid-email>\n' +
'Cannot parse as valid email address' +
' (skipping): [email protected]\n' +
'Nothing to do\n')
result.output,
'Warning: The --sync option is deprecated. '
'Use `mailman syncmembers` instead.\n'
'Cannot parse as valid email address'
' (skipping): Dont Subscribe <not-a-valid-email>\n'
'Cannot parse as valid email address'
' (skipping): [email protected]\n'
'Nothing to do\n')
def test_sync_no_change(self):
subscribe(self._mlist, 'Anne')
......@@ -205,8 +220,11 @@ class TestCLIMembers(unittest.TestCase):
print('Anne Person <[email protected]>', file=infp)
result = self._command.invoke(members, (
'--no-change', '--sync', infp.name, 'ant.example.com'))
self.assertEqual(result.output, "[DEL] Bart Person" +
" <[email protected]>\n")
self.assertEqual(
result.output,
'Warning: The --sync option is deprecated. '
'Use `mailman syncmembers` instead.\n'
'[DEL] Bart Person <[email protected]>\n')
def test_sync_empty_tuple(self):
subscribe(self._mlist, 'Anne')
......@@ -216,10 +234,12 @@ class TestCLIMembers(unittest.TestCase):
print('\"\"', file=infp)
result = self._command.invoke(members, (
'--no-change', '--sync', infp.name, 'ant.example.com'))
self.assertEqual(result.output, "Cannot parse as valid email " +
"address (skipping): \"\"\n" +
"[DEL] Bart Person " +
"<[email protected]>\n")
self.assertEqual(
result.output,
'Warning: The --sync option is deprecated. '
'Use `mailman syncmembers` instead.\n'
'Cannot parse as valid email address (skipping): ""\n'
'[DEL] Bart Person <[email protected]>\n')
def test_sync_commented_lines(self):
subscribe(self._mlist, 'Anne')
......@@ -229,8 +249,11 @@ class TestCLIMembers(unittest.TestCase):
print('#Bart Person <[email protected]>', file=infp)
result = self._command.invoke(members, (
'--sync', infp.name, 'ant.example.com'))
self.assertEqual(result.output, "[DEL] Bart Person" +
" <[email protected]>\n")
self.assertEqual(
result.output,
'Warning: The --sync option is deprecated. '
'Use `mailman syncmembers` instead.\n'
'[DEL] Bart Person <[email protected]>\n')
with NamedTemporaryFile('w', encoding='utf-8') as outfp:
self._command.invoke(members, (
......@@ -249,8 +272,11 @@ class TestCLIMembers(unittest.TestCase):
print('', file=infp)
result = self._command.invoke(members, (
'--sync', infp.name, 'ant.example.com'))
self.assertEqual(result.output, "[DEL] Bart Person" +
" <[email protected]>\n")
self.assertEqual(
result.output,
'Warning: The --sync option is deprecated. '
'Use `mailman syncmembers` instead.\n'
'[DEL] Bart Person <[email protected]>\n')
with NamedTemporaryFile('w', encoding='utf-8') as outfp:
self._command.invoke(members, (
......@@ -268,7 +294,11 @@ class TestCLIMembers(unittest.TestCase):
print('Bart Person <[email protected]>', file=infp)
result = self._command.invoke(members, (
'--sync', infp.name, 'ant.example.com'))
self.assertEqual(result.output, "Nothing to do\n")
self.assertEqual(
result.output,
'Warning: The --sync option is deprecated. '
'Use `mailman syncmembers` instead.\n'
'Nothing to do\n')
with NamedTemporaryFile('w', encoding='utf-8') as outfp:
self._command.invoke(members, (
......@@ -287,9 +317,11 @@ class TestCLIMembers(unittest.TestCase):
result = self._command.invoke(members, (
'--sync', infp.name, 'ant.example.com'))
self.assertEqual(
result.output,
"[ADD] [email protected]\n" +
"[DEL] Bart Person <[email protected]>\n")
result.output,
'Warning: The --sync option is deprecated. '
'Use `mailman syncmembers` instead.\n'
'[ADD] [email protected]\n'
'[DEL] Bart Person <[email protected]>\n')
with NamedTemporaryFile('w', encoding='utf-8') as outfp:
self._command.invoke(members, (
......@@ -310,9 +342,11 @@ class TestCLIMembers(unittest.TestCase):
result = self._command.invoke(members, (
'--sync', infp.name, 'ant.example.com'))
self.assertEqual(
result.output,
"[ADD] [email protected]\n" +
"[DEL] [email protected]\n")
result.output,
'Warning: The --sync option is deprecated. '
'Use `mailman syncmembers` instead.\n'
'[ADD] [email protected]\n'
'[DEL] [email protected]\n')
with NamedTemporaryFile('w', encoding='utf-8') as outfp:
self._command.invoke(members, (
......@@ -327,5 +361,5 @@ class TestCLIMembers(unittest.TestCase):
subscribe(self._mlist, 'Bart')
result = self._command.invoke(members, (
'--email-only', 'ant.example.com'))
self.assertEqual(result.output,
'[email protected]\n[email protected]\n')
self.assertEqual(
result.output, '[email protected]\n[email protected]\n')
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment