Skip to content

Commit

Permalink
Add --version CLI flag, and update version to 0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
wil93 committed Dec 21, 2024
1 parent 9c17bf8 commit 5769c14
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
13 changes: 10 additions & 3 deletions mailipy/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@
import email.message
import email.utils
import json
import jinja2
import markdown
import mimetypes
import pathlib
import random
import re
import sys
import yaml
from email.generator import Generator
from email.mime.application import MIMEApplication
from email.mime.audio import MIMEAudio
from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

import jinja2
import markdown
import yaml
from importlib.metadata import version


YAML_FRONT_MATTER = r"\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)(.*)"
Expand Down Expand Up @@ -207,6 +208,12 @@ def main():
parser.add_argument("template", help="a Markdown formatted document with a YAML front-matter", type=pathlib.Path)
parser.add_argument("contacts", help="a CSV file with the contacts whom to send emails to", type=pathlib.Path)
parser.add_argument("outbox", nargs="?", default=pathlib.Path("./outbox"), help="a folder where to save the emails (default: outbox)", type=pathlib.Path)
parser.add_argument(
"-v",
"--version",
action="version",
version="mailipy {v}".format(v=version("mailipy")),
)
args = parser.parse_args()

if not args.template.is_file() or args.template.suffix.lower() != ".md":
Expand Down
8 changes: 8 additions & 0 deletions mailipy/send.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import sys
import time

from importlib.metadata import version


def read_password_from_file(file_path):
with open(file_path) as f:
Expand Down Expand Up @@ -55,6 +57,12 @@ def main():
parser.add_argument("--password-file", help="path to a file containing the password to login to the mail server")
parser.add_argument("--ssl", help="SSL mode to use", choices=["auto", "none", "starttls", "ssl"], default="auto")
parser.add_argument("--sleep", help="seconds to wait after each sent email", type=int, default=0)
parser.add_argument(
"-v",
"--version",
action="version",
version="mailipy {v}".format(v=version("mailipy")),
)
args = parser.parse_args()

if not args.outbox.is_dir() or len(list(args.outbox.iterdir())) == 0:
Expand Down
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setuptools.setup(
name="mailipy",
version="0.0.8",
version="0.1",
author="William Di Luigi",
author_email="williamdiluigi@gmail.com",
description="Bulk send emails easily",
Expand All @@ -19,9 +19,9 @@
"Operating System :: OS Independent",
],
install_requires=[
'jinja2',
'markdown',
'pyyaml',
"jinja2",
"markdown",
"pyyaml",
],
python_requires='>=3.6',
python_requires=">=3.8",
)

0 comments on commit 5769c14

Please sign in to comment.