Show an item with todo-item show, and save each call with command-patterns --calls
This commit is contained in:
+16
-2
@@ -3,6 +3,7 @@
|
||||
usage: todo-item add --release <version> --l <L> --e <E> --i <I> --s <S> [--moves <moves>]
|
||||
[--blocked-by <IDs>] [--exempt <reason>] <tagline> [<<'EOF' detail EOF]
|
||||
todo-item finish <ID> [--changelog <bullet> | --no-changelog]
|
||||
todo-item show <ID>
|
||||
|
||||
Works on the todo.md in the current folder and the CHANGELOG.md beside it, and reads the README.md
|
||||
and docs/decisions.md beside todo.md.
|
||||
@@ -19,6 +20,9 @@ file, where missing. It refuses where that section holds ### subsections: add th
|
||||
Where CHANGELOG.md exists, finish needs --changelog or --no-changelog, so no bullet is left out by
|
||||
mistake. It prints `Finished item <ID>.` It writes nothing while docs/decisions.md cites the item.
|
||||
|
||||
show prints the items table's header, item <ID>'s row and its detail, from its ### heading to the next
|
||||
item's, sub-headings included. It writes nothing, and fails, saying so, where todo.md has no such row.
|
||||
|
||||
Exit 2 on bad arguments, and 1, saying why, on any other failure. A message opening `not filed:`
|
||||
or `not finished:` means it wrote nothing.
|
||||
"""
|
||||
@@ -27,7 +31,7 @@ import pathlib
|
||||
import sys
|
||||
import typing
|
||||
|
||||
from todo_item.edits import added, finished, with_bullet
|
||||
from todo_item.edits import added, finished, shown, with_bullet
|
||||
from release_plan.todo_table import BLOCKED_BY, MOVES
|
||||
from failure import Failure
|
||||
from release_plan import plan_file, ranking
|
||||
@@ -41,7 +45,10 @@ def main(argv: list[str], folder: pathlib.Path = pathlib.Path(), stdin: typing.T
|
||||
print(__doc__.strip())
|
||||
return 0
|
||||
args = parser().parse_args(argv)
|
||||
done = add(args, folder, stdin) if args.command == "add" else finish(args, folder)
|
||||
if args.command == "show":
|
||||
done = show(args, folder)
|
||||
else:
|
||||
done = add(args, folder, stdin) if args.command == "add" else finish(args, folder)
|
||||
if isinstance(done, Failure):
|
||||
print(done.reason, file=sys.stderr)
|
||||
return 1
|
||||
@@ -65,9 +72,16 @@ def parser() -> argparse.ArgumentParser:
|
||||
bullet = finishing.add_mutually_exclusive_group()
|
||||
bullet.add_argument("--changelog")
|
||||
bullet.add_argument("--no-changelog", action="store_true")
|
||||
showing = commands.add_parser("show")
|
||||
showing.add_argument("id", type=int)
|
||||
return parsed
|
||||
|
||||
|
||||
def show(args: argparse.Namespace, folder: pathlib.Path) -> str | Failure:
|
||||
texts = plan_file.read_all(folder / "todo.md")
|
||||
return texts if isinstance(texts, Failure) else shown(texts[0], args.id)
|
||||
|
||||
|
||||
def add(args: argparse.Namespace, folder: pathlib.Path, stdin: typing.TextIO) -> str | Failure:
|
||||
todo = folder / "todo.md"
|
||||
texts = plan_file.read_all(todo)
|
||||
|
||||
Reference in New Issue
Block a user