added filename arg, removed -o
This commit is contained in:
parent
f210bd0535
commit
ac1acfb908
1 changed files with 10 additions and 13 deletions
23
skratch.py
23
skratch.py
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue