feat: base task command on position instead of tags

Signed-off-by: Konstantin Fickel <mail@konstantinfickel.de>
This commit is contained in:
Konstantin Fickel 2026-01-31 20:19:00 +01:00
parent 84ad91d4c4
commit 027bf531ce
Signed by: kfickel
GPG key ID: A793722F9933C1A5
7 changed files with 61 additions and 155 deletions

View file

@ -10,36 +10,48 @@ from rich import print
from rich.markdown import Markdown
from rich.panel import Panel
from streamer.parse.attach_markdown import StreamFileWithMarkdown, attach_markdown
from streamer.parse.parse import parse_markdown_file
from streamer.query.task import find_by_markers
from streamer.localize import (
LocalizedShard,
RepositoryConfiguration,
localize_stream_file,
)
from streamer.localize.preconfigured_configurations import TaskConfiguration
from streamer.parse import parse_markdown_file
from streamer.query import find_shard_by_position
from streamer.settings import Settings
app = typer.Typer()
def all_files() -> Generator[StreamFileWithMarkdown]:
def all_files(config: RepositoryConfiguration) -> Generator[LocalizedShard]:
for file_name in glob.glob(f"{glob.escape(Settings().base_folder)}/*.md"):
with open(file_name, "r") as file:
file_content = file.read()
yield attach_markdown(
parse_markdown_file(file_name, file_content), file_content
)
if shard := localize_stream_file(
parse_markdown_file(file_name, file_content), config
):
yield shard
@app.command()
def todo() -> None:
for sharded_document in all_files():
if sharded_document.shard:
open_tasks = find_by_markers(sharded_document.shard, ["Task"], ["Done"])
all_shards = list(all_files(TaskConfiguration))
for task_shard in open_tasks:
print(
Panel(
Markdown(task_shard.markdown_content),
title=f"{sharded_document.file_name}:{task_shard.start_line}",
)
for task_shard in find_shard_by_position(all_shards, "task", "open"):
with open(task_shard.location["file"], "r") as file:
file_content = file.read().splitlines()
print(
Panel(
Markdown(
"\n".join(
file_content[
task_shard.start_line - 1 : task_shard.end_line
]
)
),
title=f"{task_shard.location['file']}:{task_shard.start_line}",
)
)
@app.command()