Skip to content
Merged
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
12 changes: 12 additions & 0 deletions devchat/_cli/log.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import os
import sys
import time
from dataclasses import dataclass, field
Expand Down Expand Up @@ -41,6 +42,17 @@ def log(skip, max_count, topic_root, insert, delete):

logger = get_logger(__name__)

# handler insert
# if insert is a file path, then read file content as "insert" value, then delete that file
try:
if os.path.isfile(insert):
insert_file = insert
with open(insert_file, "r", encoding="utf-8") as f:
insert = f.read()
os.remove(insert_file)
except Exception:
pass

if (insert or delete) and (skip != 0 or max_count != 1 or topic_root is not None):
print(
"Error: The --insert or --delete option cannot be used with other options.",
Expand Down