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