added click for command line arguments
This commit is contained in:
parent
a328c255af
commit
9b34195fdf
|
@ -19,15 +19,15 @@ package_dir =
|
||||||
= src
|
= src
|
||||||
packages = find:
|
packages = find:
|
||||||
python_requires = >=3.8
|
python_requires = >=3.8
|
||||||
#install_requires =
|
install_requires =
|
||||||
# dependency
|
click
|
||||||
|
|
||||||
[options.packages.find]
|
[options.packages.find]
|
||||||
where = src
|
where = src
|
||||||
|
|
||||||
[options.entry_points]
|
[options.entry_points]
|
||||||
console_scripts =
|
console_scripts =
|
||||||
remember-remember-bot = remember_remember_bot.loop:loop
|
remember-remember-bot = remember_remember_bot.cli:main
|
||||||
|
|
||||||
[tox:tox]
|
[tox:tox]
|
||||||
envlist = lint, py310
|
envlist = lint, py310
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
def main() -> None:
|
|
||||||
print("Hello World")
|
|
|
@ -1,3 +0,0 @@
|
||||||
from . import main
|
|
||||||
|
|
||||||
main()
|
|
29
src/remember_remember_bot/cli.py
Normal file
29
src/remember_remember_bot/cli.py
Normal file
|
@ -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()
|
Loading…
Reference in a new issue