added -s file suffix

This commit is contained in:
phixxy 2026-03-05 14:55:45 -08:00
parent 842daf7924
commit cd8184dc7c

View file

@ -39,11 +39,11 @@ def get_editor(use_v):
return v
return e
def run(editor, sk_path, filename=None):
def run(editor, sk_path, filename=None, f_suffix=""):
if not filename:
t = time.localtime()
filename = f"skratch-{t.tm_year}-{t.tm_mon}-{t.tm_mday}-"
fd, fp = tempfile.mkstemp(prefix=filename, dir=sk_path)
fd, fp = tempfile.mkstemp(prefix=filename, dir=sk_path, suffix=f_suffix)
os.close(fd)
else:
fp = os.path.join(sk_path, filename)
@ -77,6 +77,11 @@ def main():
help="list files",
action="store_true")
group.add_argument(
"-s",
help="add suffix",
action="store")
parser.add_argument(
"-v",
help="visual editor",
@ -87,6 +92,6 @@ def main():
editor = get_editor(args.v)
if args.c: delete_all(sk_path)
elif args.l: list_all(sk_path)
else: run(editor,sk_path, args.filename)
else: run(editor,sk_path, args.filename, args.s)
main()