added filename arg, removed -o

This commit is contained in:
phixxy 2026-03-05 14:28:22 -08:00
parent f210bd0535
commit ac1acfb908

View file

@ -1,5 +1,4 @@
#!/usr/bin/python3
import sys
import os
import argparse
@ -64,7 +63,15 @@ def main():
prog='skratch',
description='Creates a temp file and opens it in an editor',
epilog='Text at the bottom of help')
group = parser.add_mutually_exclusive_group()
group.add_argument(
"filename",
nargs="?",
help="open file in ~/.skratch",
default=None)
group.add_argument(
"-c",
help="delete all files",
@ -75,12 +82,6 @@ def main():
help="list files",
action="store_true")
group.add_argument(
"-o",
metavar="<file>",
help="open file",
action="store")
parser.add_argument(
"-v",
help="visual editor",
@ -88,13 +89,9 @@ def main():
args = parser.parse_args()
filename = "skratch-XXXXXX"
editor = get_editor(args.v)
if args.o: run(editor,sk_path,args.o)
elif args.c: delete_all(sk_path)
if args.c: delete_all(sk_path)
elif args.l: list_all(sk_path)
else: run(editor,sk_path)
else: run(editor,sk_path, args.filename)
main()