Abhilash Raj pushed to branch master at GNU Mailman / Mailman Core
Commits: e1500740 by Daniel Teichmann at 2019-08-25T18:42:01Z Add docs for ``mailman members --delete`` command. - - - - - e8c62280 by Abhilash Raj at 2019-08-25T18:42:01Z Merge branch 'mr/remove_members_cmd_docs' into 'master' Add docs for ``mailman members --delete`` command See merge request mailman/mailman!547 - - - - - 1 changed file: - src/mailman/commands/docs/members.rst Changes: ===================================== src/mailman/commands/docs/members.rst ===================================== @@ -3,7 +3,7 @@ Managing members ================ The ``mailman members`` command allows a site administrator to display, add, -and remove members from a mailing list. +and delete members from a mailing list. >>> command = cli('mailman.commands.cli_members.members') @@ -252,18 +252,96 @@ printed. jper...@example.com -Displaying members -================== +Deleting members +============== -With no arguments, the command displays all members of the list. +You can delete members from a mailing list from the command line. To do so, you +need a file containing email addresses and full names that can be parsed by +``email.utils.parseaddr()``. All mail addresses in the file will be deleted +from the mailing list. - >>> command('mailman members bee.example.com') - aper...@example.com +Assuming you have populated a mailing list with the code examples from above, +use these code snippets to delete subscriptions from the list again. +:: + + >>> with open(filename, 'w', encoding='utf-8') as fp: + ... print("""\ + ... aper...@example.com + ... cper...@example.com (Cate Person) + ... """, file=fp) + + >>> command('mailman members --delete ' + filename + ' bee.example.com') + + >>> from operator import attrgetter + >>> dump_list(bee.members.addresses, key=attrgetter('email')) Bart Person <bper...@example.com> - Cate Person <cper...@example.com> dper...@example.com Elly Person <eper...@example.com> Fred Person <fper...@example.com> gper...@example.com iper...@example.com jper...@example.com + +You can also specify ``-`` as the filename, in which case the addresses are +taken from standard input. +:: + + >>> stdin = """\ + ... dper...@example.com + ... Elly Person <eper...@example.com> + ... """ + >>> command('mailman members --delete - bee.example.com', input=stdin) + + >>> dump_list(bee.members.addresses, key=attrgetter('email')) + Bart Person <bper...@example.com> + Fred Person <fper...@example.com> + gper...@example.com + iper...@example.com + jper...@example.com + +Blank lines and lines that begin with '#' are ignored. +:: + + >>> with open(filename, 'w', encoding='utf-8') as fp: + ... print("""\ + ... # cper...@example.com + ... + ... bper...@example.com + ... """, file=fp) + + >>> command('mailman members --delete ' + filename + ' bee.example.com') + + >>> dump_list(bee.members.addresses, key=attrgetter('email')) + Fred Person <fper...@example.com> + gper...@example.com + iper...@example.com + jper...@example.com + +Addresses which are not subscribed are ignored, although a warning is +printed. +:: + + >>> with open(filename, 'w', encoding='utf-8') as fp: + ... print("""\ + ... kper...@example.com + ... iper...@example.com + ... """, file=fp) + + >>> command('mailman members --delete ' + filename + ' bee.example.com') + Member not subscribed (skipping): kper...@example.com + + >>> dump_list(bee.members.addresses, key=attrgetter('email')) + Fred Person <fper...@example.com> + gper...@example.com + jper...@example.com + + +Displaying members +================== + +With no arguments, the command displays all members of the list. + + >>> command('mailman members bee.example.com') + Fred Person <fper...@example.com> + gper...@example.com + jper...@example.com View it on GitLab: https://gitlab.com/mailman/mailman/compare/e8ef9a8a63af7cb30dce15bdcaf5be14d1ad3d43...e8c622809eb08c55c59ba8118043bfe5add8a14b -- View it on GitLab: https://gitlab.com/mailman/mailman/compare/e8ef9a8a63af7cb30dce15bdcaf5be14d1ad3d43...e8c622809eb08c55c59ba8118043bfe5add8a14b You're receiving this email because of your account on gitlab.com.
_______________________________________________ Mailman-checkins mailing list Mailman-checkins@python.org Unsubscribe: https://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org