Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions hermes_cli/kanban.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,8 @@ def build_parser(parent_subparsers: argparse._SubParsersAction) -> argparse.Argu
p_comment.add_argument("text", nargs="+", help="Comment body")
p_comment.add_argument("--author", default=None,
help="Author name (default: $HERMES_PROFILE or 'user')")
p_comment.add_argument("--max-len", type=int, default=None,
help="Trim the stored comment body to this many characters")

p_complete = sub.add_parser("complete", help="Mark one or more tasks done")
p_complete.add_argument("task_ids", nargs="+",
Expand Down Expand Up @@ -1616,6 +1618,13 @@ def _cmd_claim(args: argparse.Namespace) -> int:

def _cmd_comment(args: argparse.Namespace) -> int:
body = " ".join(args.text).strip()
if args.max_len is not None:
if args.max_len < 1:
print("kanban: --max-len must be positive", file=sys.stderr)
return 2
if len(body) > args.max_len:
suffix = f"\n\n[trimmed to {args.max_len} chars by --max-len]"
body = body[: max(0, args.max_len - len(suffix))].rstrip() + suffix
author = args.author or _profile_author()
with kb.connect() as conn:
kb.add_comment(conn, args.task_id, author, body)
Expand Down
14 changes: 12 additions & 2 deletions tests/hermes_cli/test_kanban_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,19 @@ def test_run_slash_show_includes_comments(kanban_home):
out = kc.run_slash("create 'x'")
import re
tid = re.search(r"(t_[a-f0-9]+)", out).group(1)
kc.run_slash(f"comment {tid} 'source is paywalled'")
kc.run_slash(f"comment {tid} 'remember to include performance section'")
show = kc.run_slash(f"show {tid}")
assert "performance section" in show


def test_run_slash_comment_max_len_trims_long_body(kanban_home):
out = kc.run_slash("create 'x'")
import re
tid = re.search(r"(t_[a-f0-9]+)", out).group(1)
kc.run_slash(f"comment {tid} '{'x' * 30}' --max-len 20")
show = kc.run_slash(f"show {tid}")
assert "source is paywalled" in show
assert "trimmed to 20 chars by --max-len" in show
assert "x" * 30 not in show


def test_run_slash_block_unblock_cycle(kanban_home):
Expand Down
Loading