Add options to omit filename and timestamp

This commit is contained in:
Peter J. Holzer 2025-02-18 10:56:21 +01:00 committed by Peter J. Holzer
parent 29491e1639
commit 25717fff98
1 changed files with 13 additions and 1 deletions

14
kitsune
View File

@ -88,7 +88,13 @@ def watch(args):
if lines[-1] == "":
lines.pop()
for ln in lines:
print(f"{f.path:{filename_length}}", format_ts(f.last_ts), dead, ln)
s = ""
if args.print_filename:
s += f"{f.path:{filename_length}} "
if args.print_timestamp:
s += format_ts(f.last_ts) + " "
s += dead + " " + ln
print(s)
else:
try:
stf = os.stat(f.path)
@ -109,6 +115,12 @@ if __name__ == "__main__":
ap.add_argument("--match-filename",
help="follow only matching files in directories",
metavar="GLOB-PATTERN")
ap.add_argument("--no-filename", "--no-print-filename", action="store_false",
dest="print_filename",
help="don't print filename in each line")
ap.add_argument("--no-timestamp", "--no-print-timestamp", action="store_false",
dest="print_timestamp",
help="don't print timestamp in each line")
ap.add_argument("files", nargs="*", default=["."],
metavar="file")
args = ap.parse_args()