extract cli to separate dir.

default create parents .plan dir.
This commit is contained in:
GitMatt 2025-01-28 05:48:58 -08:00
parent 02dde14630
commit e1575c85a1
5 changed files with 36 additions and 11 deletions

View File

@ -5,10 +5,15 @@ description = "edit ~/.plan files"
authors = [{ name = "gitmatt", email = "git@publicmatt.com" }] authors = [{ name = "gitmatt", email = "git@publicmatt.com" }]
readme = "README.md" readme = "README.md"
requires-python = ">=3.12" requires-python = ">=3.12"
dependencies = ["click>=8.1.8", "jinja2>=3.1.5", "rich>=13.9.4"] dependencies = [
"click>=8.1.8",
"click-default-group>=1.2.4",
"jinja2>=3.1.5",
"rich>=13.9.4",
]
[project.scripts] [project.scripts]
plan = "plan:__main__.main" plan = "plan:cli.cli"
[build-system] [build-system]
requires = ["hatchling"] requires = ["hatchling"]

View File

@ -1,8 +0,0 @@
import click
from .path import open, today
@click.command()
def main():
open(today())

13
src/plan/cli.py Normal file
View File

@ -0,0 +1,13 @@
import click
from click_default_group import DefaultGroup
from .path import open, today
@click.group(cls=DefaultGroup, default="today", default_if_no_args=True)
def cli():
pass
@cli.command("today")
def open_today():
open(today())

View File

@ -14,6 +14,7 @@ def today() -> Path:
def open(plan: Path): def open(plan: Path):
import subprocess import subprocess
plan.parent.mkdir(parents=True, exist_ok=True)
if not plan.exists(): if not plan.exists():
plan.touch() plan.touch()
with plan.open("w") as f: with plan.open("w") as f:

16
uv.lock
View File

@ -13,6 +13,18 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/7e/d4/7ebdbd03970677812aac39c869717059dbb71a4cfc033ca6e5221787892c/click-8.1.8-py3-none-any.whl", hash = "sha256:63c132bbbed01578a06712a2d1f497bb62d9c1c0d329b7903a866228027263b2", size = 98188 }, { url = "https://files.pythonhosted.org/packages/7e/d4/7ebdbd03970677812aac39c869717059dbb71a4cfc033ca6e5221787892c/click-8.1.8-py3-none-any.whl", hash = "sha256:63c132bbbed01578a06712a2d1f497bb62d9c1c0d329b7903a866228027263b2", size = 98188 },
] ]
[[package]]
name = "click-default-group"
version = "1.2.4"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "click" },
]
sdist = { url = "https://files.pythonhosted.org/packages/1d/ce/edb087fb53de63dad3b36408ca30368f438738098e668b78c87f93cd41df/click_default_group-1.2.4.tar.gz", hash = "sha256:eb3f3c99ec0d456ca6cd2a7f08f7d4e91771bef51b01bdd9580cc6450fe1251e", size = 3505 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/2c/1a/aff8bb287a4b1400f69e09a53bd65de96aa5cee5691925b38731c67fc695/click_default_group-1.2.4-py2.py3-none-any.whl", hash = "sha256:9b60486923720e7fc61731bdb32b617039aba820e22e1c88766b1125592eaa5f", size = 4123 },
]
[[package]] [[package]]
name = "colorama" name = "colorama"
version = "0.4.6" version = "0.4.6"
@ -95,10 +107,11 @@ wheels = [
[[package]] [[package]]
name = "plan" name = "plan"
version = "0.1.0" version = "0.1.1"
source = { editable = "." } source = { editable = "." }
dependencies = [ dependencies = [
{ name = "click" }, { name = "click" },
{ name = "click-default-group" },
{ name = "jinja2" }, { name = "jinja2" },
{ name = "rich" }, { name = "rich" },
] ]
@ -106,6 +119,7 @@ dependencies = [
[package.metadata] [package.metadata]
requires-dist = [ requires-dist = [
{ name = "click", specifier = ">=8.1.8" }, { name = "click", specifier = ">=8.1.8" },
{ name = "click-default-group", specifier = ">=1.2.4" },
{ name = "jinja2", specifier = ">=3.1.5" }, { name = "jinja2", specifier = ">=3.1.5" },
{ name = "rich", specifier = ">=13.9.4" }, { name = "rich", specifier = ">=13.9.4" },
] ]