diff --git a/pyproject.toml b/pyproject.toml index e62dbc0..fa96012 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,6 +13,7 @@ dependencies = [ "markdown>=3.7", "md2py>=0.0.1", "pydantic>=2.10.6", + "pydantic-settings>=2.10.1", "rich>=13.9.4", ] diff --git a/src/plan/__init__.py b/src/plan/__init__.py index 4db2f5f..e36254c 100644 --- a/src/plan/__init__.py +++ b/src/plan/__init__.py @@ -6,6 +6,10 @@ from pathlib import Path from jinja2 import Environment, PackageLoader, select_autoescape +from .config import Config + +config = Config() + def get_template(template_name: str = "plan.html", plan_path: Path | None = None): """ """ @@ -22,7 +26,7 @@ def plan_path() -> Path: returns: Path to current date's .plan.md """ today = datetime.today().strftime("%Y-%m-%d") - path = Path().home() / ".plan" / f"{today}.md" + path = config.app_path / f"{today}.md" return path diff --git a/src/plan/cli.py b/src/plan/cli.py index 145dbd5..8520f5d 100644 --- a/src/plan/cli.py +++ b/src/plan/cli.py @@ -30,29 +30,25 @@ def send_to_printer(plan_path: Path): @cli.command("main") -@click.option( - "-t", - "--template", - "template", - required=True, - type=click.Choice(["plan.html", "work.html"]), - prompt=True, - default="plan.html", - show_default=True, -) +@click.argument("template_name", required=True, default="plan.html") @click.option( "--print/--no-print", - "should_print", + "is_print", is_flag=True, default=False, - prompt="print template only?", - required=True, ) -def open_today(template, should_print): - """open today""" +@click.option("--quiet", "quiet", type=bool, is_flag=True, default=True) +def open_today(template_name, is_print: bool = False, quiet: bool = True): + """ + open today + + plan {:template|plan.html} {--quiet} {--print} + + :template can be one of: {plan|work}.html + """ path = plan_path() - content = create_plan(plan_path=path, name=template) - if should_print: + content = create_plan(plan_path=path, name=template_name) + if is_print: print(content) else: sys.exit(edit_plan(path)) diff --git a/src/plan/config.py b/src/plan/config.py new file mode 100644 index 0000000..590ca57 --- /dev/null +++ b/src/plan/config.py @@ -0,0 +1,14 @@ +from pathlib import Path + +from pydantic import Field +from pydantic_settings import BaseSettings + + +def default_app_path(): + path = Path().home() / ".plan" + return path + + +class Config(BaseSettings): + model_config = {"env_file": ".env", "env_prefix": "PLAN_", "extra": "ignore"} + app_path: Path = Field(default_factory=default_app_path) diff --git a/src/plan/main.py b/src/plan/main.py index aeaf42f..8a785d4 100644 --- a/src/plan/main.py +++ b/src/plan/main.py @@ -3,9 +3,12 @@ import subprocess import sys from datetime import datetime from pathlib import Path +from .config import Config from jinja2 import Environment, PackageLoader, select_autoescape +config = Config() + def get_template(template_name: str = "plan.html", plan_path: Path | None = None): """ """ @@ -23,8 +26,8 @@ def plan_path(date: datetime | None = None) -> Path: """ if date is None: date = datetime.today() - formatted = date.strftime("%Y-%m-%d") - path = Path().home() / ".plan" / f"{formatted}.md" + today = date.strftime("%Y-%m-%d") + path = config.app_path / f"{today}.md" return path diff --git a/src/plan/templates/plan.html b/src/plan/templates/plan.html index 20a5830..7b75c7a 100644 --- a/src/plan/templates/plan.html +++ b/src/plan/templates/plan.html @@ -1,8 +1,25 @@ # .plan: {{ today }} -## todo +## mission - appreciate life. +- embrace changes. +- stay active. +- seek adventure. +- you are (k)enough + + +## feelings + +- how do I feel? + +- where/what do I feel in my body? + +- what thoughts go with how I feel? + +- what am I believing about myself, others and the world? + +## todo ## meals diff --git a/uv.lock b/uv.lock index ef14eb7..63aed5d 100644 --- a/uv.lock +++ b/uv.lock @@ -222,6 +222,7 @@ dependencies = [ { name = "markdown" }, { name = "md2py" }, { name = "pydantic" }, + { name = "pydantic-settings" }, { name = "rich" }, ] @@ -240,6 +241,7 @@ requires-dist = [ { name = "markdown", specifier = ">=3.7" }, { name = "md2py", specifier = ">=0.0.1" }, { name = "pydantic", specifier = ">=2.10.6" }, + { name = "pydantic-settings", specifier = ">=2.10.1" }, { name = "rich", specifier = ">=13.9.4" }, ] @@ -311,6 +313,20 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/51/b2/b2b50d5ecf21acf870190ae5d093602d95f66c9c31f9d5de6062eb329ad1/pydantic_core-2.27.2-cp313-cp313-win_arm64.whl", hash = "sha256:ac4dbfd1691affb8f48c2c13241a2e3b60ff23247cbcf981759c768b6633cf8b", size = 1885186 }, ] +[[package]] +name = "pydantic-settings" +version = "2.10.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pydantic" }, + { name = "python-dotenv" }, + { name = "typing-inspection" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/68/85/1ea668bbab3c50071ca613c6ab30047fb36ab0da1b92fa8f17bbc38fd36c/pydantic_settings-2.10.1.tar.gz", hash = "sha256:06f0062169818d0f5524420a360d632d5857b83cffd4d42fe29597807a1614ee", size = 172583 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/58/f0/427018098906416f580e3cf1366d3b1abfb408a0652e9f31600c24a1903c/pydantic_settings-2.10.1-py3-none-any.whl", hash = "sha256:a60952460b99cf661dc25c29c0ef171721f98bfcb52ef8d9ea4c943d7c8cc796", size = 45235 }, +] + [[package]] name = "pygments" version = "2.19.1" @@ -335,6 +351,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/11/92/76a1c94d3afee238333bc0a42b82935dd8f9cf8ce9e336ff87ee14d9e1cf/pytest-8.3.4-py3-none-any.whl", hash = "sha256:50e16d954148559c9a74109af1eaf0c945ba2d8f30f0a3d3335edde19788b6f6", size = 343083 }, ] +[[package]] +name = "python-dotenv" +version = "1.1.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/f6/b0/4bc07ccd3572a2f9df7e6782f52b0c6c90dcbb803ac4a167702d7d0dfe1e/python_dotenv-1.1.1.tar.gz", hash = "sha256:a8a6399716257f45be6a007360200409fce5cda2661e3dec71d23dc15f6189ab", size = 41978 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/5f/ed/539768cf28c661b5b068d66d96a2f155c4971a5d55684a514c1a0e0dec2f/python_dotenv-1.1.1-py3-none-any.whl", hash = "sha256:31f23644fe2602f88ff55e1f5c79ba497e01224ee7737937930c448e4d0e24dc", size = 20556 }, +] + [[package]] name = "rich" version = "13.9.4" @@ -366,6 +391,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/26/9f/ad63fc0248c5379346306f8668cda6e2e2e9c95e01216d2b8ffd9ff037d0/typing_extensions-4.12.2-py3-none-any.whl", hash = "sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d", size = 37438 }, ] +[[package]] +name = "typing-inspection" +version = "0.4.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/f8/b1/0c11f5058406b3af7609f121aaa6b609744687f1d158b3c3a5bf4cc94238/typing_inspection-0.4.1.tar.gz", hash = "sha256:6ae134cc0203c33377d43188d4064e9b357dba58cff3185f22924610e70a9d28", size = 75726 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/17/69/cd203477f944c353c31bade965f880aa1061fd6bf05ded0726ca845b6ff7/typing_inspection-0.4.1-py3-none-any.whl", hash = "sha256:389055682238f53b04f7badcb49b989835495a96700ced5dab2d8feae4b26f51", size = 14552 }, +] + [[package]] name = "wat" version = "0.5.0"