diff --git a/pyproject.toml b/pyproject.toml index d1d913c..291a507 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "tyora" -version = "0.1.0" +version = "0.0.1" description = "CLI to interact with the mooc.fi instance of CSES" license = "MIT" authors = [ diff --git a/src/tyora/__init__.py b/src/tyora/__init__.py index 86cb342..e291ba0 100644 --- a/src/tyora/__init__.py +++ b/src/tyora/__init__.py @@ -1,4 +1,5 @@ import argparse +import importlib.metadata import json import logging from dataclasses import dataclass, field @@ -15,6 +16,10 @@ from html2text import html2text logger = logging.getLogger(name="tyora") +try: + __version__ = importlib.metadata.version("tyora") +except importlib.metadata.PackageNotFoundError: + __version__ = "unknown" @dataclass @@ -102,6 +107,9 @@ def http_request( def parse_args(args: Optional[list[str]] = None) -> argparse.Namespace: parser = argparse.ArgumentParser(description="Interact with mooc.fi CSES instance") + parser.add_argument( + "--version", action="version", version=f"%(prog)s {__version__}" + ) parser.add_argument("--username", help="tmc.mooc.fi username") parser.add_argument("--password", help="tmc.mooc.fi password") parser.add_argument(