add new default template.
use .env PLAN_APP_PATH via pydantic_settings.
This commit is contained in:
parent
a30cee6bb9
commit
5411e55c17
|
@ -13,6 +13,7 @@ dependencies = [
|
||||||
"markdown>=3.7",
|
"markdown>=3.7",
|
||||||
"md2py>=0.0.1",
|
"md2py>=0.0.1",
|
||||||
"pydantic>=2.10.6",
|
"pydantic>=2.10.6",
|
||||||
|
"pydantic-settings>=2.10.1",
|
||||||
"rich>=13.9.4",
|
"rich>=13.9.4",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,10 @@ from pathlib import Path
|
||||||
|
|
||||||
from jinja2 import Environment, PackageLoader, select_autoescape
|
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):
|
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
|
returns: Path to current date's .plan.md
|
||||||
"""
|
"""
|
||||||
today = datetime.today().strftime("%Y-%m-%d")
|
today = datetime.today().strftime("%Y-%m-%d")
|
||||||
path = Path().home() / ".plan" / f"{today}.md"
|
path = config.app_path / f"{today}.md"
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,29 +30,25 @@ def send_to_printer(plan_path: Path):
|
||||||
|
|
||||||
|
|
||||||
@cli.command("main")
|
@cli.command("main")
|
||||||
@click.option(
|
@click.argument("template_name", required=True, default="plan.html")
|
||||||
"-t",
|
|
||||||
"--template",
|
|
||||||
"template",
|
|
||||||
required=True,
|
|
||||||
type=click.Choice(["plan.html", "work.html"]),
|
|
||||||
prompt=True,
|
|
||||||
default="plan.html",
|
|
||||||
show_default=True,
|
|
||||||
)
|
|
||||||
@click.option(
|
@click.option(
|
||||||
"--print/--no-print",
|
"--print/--no-print",
|
||||||
"should_print",
|
"is_print",
|
||||||
is_flag=True,
|
is_flag=True,
|
||||||
default=False,
|
default=False,
|
||||||
prompt="print template only?",
|
|
||||||
required=True,
|
|
||||||
)
|
)
|
||||||
def open_today(template, should_print):
|
@click.option("--quiet", "quiet", type=bool, is_flag=True, default=True)
|
||||||
"""open today"""
|
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()
|
path = plan_path()
|
||||||
content = create_plan(plan_path=path, name=template)
|
content = create_plan(plan_path=path, name=template_name)
|
||||||
if should_print:
|
if is_print:
|
||||||
print(content)
|
print(content)
|
||||||
else:
|
else:
|
||||||
sys.exit(edit_plan(path))
|
sys.exit(edit_plan(path))
|
||||||
|
|
|
@ -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)
|
|
@ -3,9 +3,12 @@ import subprocess
|
||||||
import sys
|
import sys
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from .config import Config
|
||||||
|
|
||||||
from jinja2 import Environment, PackageLoader, select_autoescape
|
from jinja2 import Environment, PackageLoader, select_autoescape
|
||||||
|
|
||||||
|
config = Config()
|
||||||
|
|
||||||
|
|
||||||
def get_template(template_name: str = "plan.html", plan_path: Path | None = None):
|
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:
|
if date is None:
|
||||||
date = datetime.today()
|
date = datetime.today()
|
||||||
formatted = date.strftime("%Y-%m-%d")
|
today = date.strftime("%Y-%m-%d")
|
||||||
path = Path().home() / ".plan" / f"{formatted}.md"
|
path = config.app_path / f"{today}.md"
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,25 @@
|
||||||
# .plan: {{ today }}
|
# .plan: {{ today }}
|
||||||
|
|
||||||
## todo
|
## mission
|
||||||
|
|
||||||
- appreciate life.
|
- 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
|
## meals
|
||||||
|
|
||||||
|
|
37
uv.lock
37
uv.lock
|
@ -222,6 +222,7 @@ dependencies = [
|
||||||
{ name = "markdown" },
|
{ name = "markdown" },
|
||||||
{ name = "md2py" },
|
{ name = "md2py" },
|
||||||
{ name = "pydantic" },
|
{ name = "pydantic" },
|
||||||
|
{ name = "pydantic-settings" },
|
||||||
{ name = "rich" },
|
{ name = "rich" },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -240,6 +241,7 @@ requires-dist = [
|
||||||
{ name = "markdown", specifier = ">=3.7" },
|
{ name = "markdown", specifier = ">=3.7" },
|
||||||
{ name = "md2py", specifier = ">=0.0.1" },
|
{ name = "md2py", specifier = ">=0.0.1" },
|
||||||
{ name = "pydantic", specifier = ">=2.10.6" },
|
{ name = "pydantic", specifier = ">=2.10.6" },
|
||||||
|
{ name = "pydantic-settings", specifier = ">=2.10.1" },
|
||||||
{ name = "rich", specifier = ">=13.9.4" },
|
{ 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 },
|
{ 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]]
|
[[package]]
|
||||||
name = "pygments"
|
name = "pygments"
|
||||||
version = "2.19.1"
|
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 },
|
{ 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]]
|
[[package]]
|
||||||
name = "rich"
|
name = "rich"
|
||||||
version = "13.9.4"
|
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 },
|
{ 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]]
|
[[package]]
|
||||||
name = "wat"
|
name = "wat"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
|
|
Loading…
Reference in New Issue