From 9b34195fdffee299a2e718ad406f93f3f1e7879a Mon Sep 17 00:00:00 2001 From: missytake Date: Fri, 1 Sep 2023 14:51:22 +0200 Subject: [PATCH] added click for command line arguments --- setup.cfg | 6 +++--- src/remember_remember_bot/__init__.py | 2 -- src/remember_remember_bot/__main__.py | 3 --- src/remember_remember_bot/cli.py | 29 +++++++++++++++++++++++++++ 4 files changed, 32 insertions(+), 8 deletions(-) delete mode 100644 src/remember_remember_bot/__main__.py create mode 100644 src/remember_remember_bot/cli.py diff --git a/setup.cfg b/setup.cfg index 9653582..c561dd3 100644 --- a/setup.cfg +++ b/setup.cfg @@ -19,15 +19,15 @@ package_dir = = src packages = find: python_requires = >=3.8 -#install_requires = -# dependency +install_requires = + click [options.packages.find] where = src [options.entry_points] console_scripts = - remember-remember-bot = remember_remember_bot.loop:loop + remember-remember-bot = remember_remember_bot.cli:main [tox:tox] envlist = lint, py310 diff --git a/src/remember_remember_bot/__init__.py b/src/remember_remember_bot/__init__.py index 9169e98..e69de29 100644 --- a/src/remember_remember_bot/__init__.py +++ b/src/remember_remember_bot/__init__.py @@ -1,2 +0,0 @@ -def main() -> None: - print("Hello World") diff --git a/src/remember_remember_bot/__main__.py b/src/remember_remember_bot/__main__.py deleted file mode 100644 index 8273c4f..0000000 --- a/src/remember_remember_bot/__main__.py +++ /dev/null @@ -1,3 +0,0 @@ -from . import main - -main() diff --git a/src/remember_remember_bot/cli.py b/src/remember_remember_bot/cli.py new file mode 100644 index 0000000..d52cfd7 --- /dev/null +++ b/src/remember_remember_bot/cli.py @@ -0,0 +1,29 @@ +import click +import remember_remember_bot.loop + + +@click.command() +@click.option("--email", type=str, default=None, help="the email account for the bot") +@click.option("--password", type=str, default=None, help="the password of the email account") +@click.option("--db", type=str, default="remember.db/db.sqlite", help="path to the bot's database") +@click.option("--debug", is_flag=True, default=False, help="show low level delta chat ffi events") +@click.pass_context +def run(ctx, email: str, password: str, db: str, debug: bool): + """Remember, remember, the 5th of November... a Delta Chat bot to send daily reminders. + + :param ctx: the click context + :param email: the email account for the bot, e.g. bot@example.org + :param password: the password for the email account + :param db: the path to the database + :param debug: whether to show low-level deltachat FFI events + """ + # setup + remember_remember_bot.loop.loop() + + +def main(): + run(auto_envvar_prefix='REMEMBER') + + +if __name__ == "__main__": + main()