Skip to content

Commit

Permalink
Add login command to main
Browse files Browse the repository at this point in the history
  • Loading branch information
wvanhed committed Dec 26, 2023
1 parent 4bf795c commit 78f3c19
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/mijnbib/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,25 @@
import pprint as pp
import sys

from mijnbib import MijnBibliotheek
from mijnbib import AuthenticationError, MijnBibliotheek

CONFIG_FILE = "mijnbib.ini"


def _do_login(args: argparse.Namespace):
print("Trying to log in ...")

print(f"City: : {args.city}")
print(f"Username : {args.username}")

mb = MijnBibliotheek(args.username, args.password, args.city)
try:
mb.login()
except AuthenticationError as e:
print(str(e))
print(f"Logged in: {mb._logged_in}")


def _do_all(args: argparse.Namespace):
print("Retrieving all information ...")

Expand Down Expand Up @@ -98,6 +112,10 @@ def main():
"reservations", parents=[common_parser], help="retrieve reservations for account id"
)
parser_all.set_defaults(func=_do_reservations)
parser_all = subparsers.add_parser(
"login", parents=[common_parser], help="just log in, and report if success or not"
)
parser_all.set_defaults(func=_do_login)

# Add values from ini file as default values
config = configparser.ConfigParser()
Expand Down

0 comments on commit 78f3c19

Please sign in to comment.