From 97028f8bd2b67b7318ba27796f4dc672264649ba Mon Sep 17 00:00:00 2001 From: shockrah Date: Tue, 15 Dec 2020 14:22:29 -0800 Subject: [PATCH] better note about configs and added support for config comments --- chan-like/channer.py | 2 ++ chan-like/readme.md | 23 +++++++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/chan-like/channer.py b/chan-like/channer.py index 4f05297..272af21 100644 --- a/chan-like/channer.py +++ b/chan-like/channer.py @@ -46,6 +46,8 @@ def read_config(path: str) -> dict: with open(path, 'r') as cfg: # Line format key=value for line in cfg: + if line.startswith('#'): + continue line = line.strip() key = line[:line.find('=')] value = line[line.find('=')+1:] diff --git a/chan-like/readme.md b/chan-like/readme.md index bbe2638..2d389da 100644 --- a/chan-like/readme.md +++ b/chan-like/readme.md @@ -7,15 +7,26 @@ This is basically another chronjob script that will execute every few minutes or ## Options and what they do -* time-out [VALUE] : sets an expiration timer for messages (on the order of days) +-h --help : Shows a help message then exits -Example : `--time-out 30` messages older than 30 days will be deletede +-m MAX_AGE_DAYS --max-age-days MAX_AGE_DAYS : Sets how old messages are allowed to be to avoid deletion(in days) -* message-limit [VALUE] : sets the max number of messages allowed in each channel +Example `-m 7` deletes messages older than 7 days. -Example : `--message-limit 1000` after 1000 messages the oldest message will be removed to keep the amount of messages to around 1000. +-f FILE_ENV --file-env FILE_ENV : **Required** path to config file. See example below. -NOTE : this creates a new process if --no-poll is specified +``` +# Lines starting with '#' are ignored as comments +# No spaces between the keyname and '=' sign and value on the right +# '"' marks are also not required +# Keys the script doesn't care about are ignored +DATABASE_URL=mysql://user-account-to-use-the-db:supersecretpassword123@db.host.provider.io:3306/dbname-example -* --no-poll : Opt out of polling and listen for changes in the database +# Below are all the required keys for the script to work, the rest are ignored +DATABASE_NAME=dbname-example +DATABASE_PASS=supersecretpassword123 +DATABASE_USER=user-account-to-use-the-db +DATABASE_HOST=db.host.provider.io +DATABASE_PORT=3306 +```