|
|
|
@ -6,10 +6,11 @@ import opener |
|
|
|
import pyperclip |
|
|
|
import searcher |
|
|
|
parser = argparse.ArgumentParser(prog='ext-open',prefix_chars=prefix_char) |
|
|
|
for opt in prefix: |
|
|
|
parser.add_argument(*opt.pop('ostring'),**opt) |
|
|
|
sub_parsers = parser.add_subparsers(dest='ext') |
|
|
|
exe_parser = sub_parsers.add_parser('exe',prefix_chars=prefix_char) |
|
|
|
update_parser = sub_parsers.add_parser('update',prefix_chars=prefix_char) |
|
|
|
for opt in prefix: |
|
|
|
update_parser.add_argument(*opt.pop('ostring'),**opt) |
|
|
|
for opt in exe: |
|
|
|
opt = opt.copy() |
|
|
|
exe_parser.add_argument(*opt.pop('ostring'),**opt) |
|
|
|
@ -18,11 +19,12 @@ for ext in exts: |
|
|
|
for opt in ext['opts']+common: |
|
|
|
opt = opt.copy() |
|
|
|
sub_parser.add_argument(*opt.pop('ostring'),**opt) |
|
|
|
if __name__ == '__main__': |
|
|
|
if __name__ == "__main__": |
|
|
|
args = parser.parse_args() |
|
|
|
print(args) |
|
|
|
ext = args.ext |
|
|
|
s = searcher.Searcher(ext,args.case_sensitive) |
|
|
|
if ext == 'update': |
|
|
|
ext = args.update_ext |
|
|
|
s = searcher.Searcher(ext) |
|
|
|
if args.trim_history is not None: |
|
|
|
if args.trim_history.lower() == 'all': |
|
|
|
if input('Are you sure?\n(y/n): ') == 'y': |
|
|
|
@ -30,9 +32,9 @@ if __name__ == '__main__': |
|
|
|
elif args.trim_history.isdecimal: |
|
|
|
n = int(args.trim_history) |
|
|
|
s.clean(n) |
|
|
|
del args.__dict__['trim_history'] |
|
|
|
if args.__dict__.pop('update'): |
|
|
|
s.update() |
|
|
|
else: |
|
|
|
s = searcher.Searcher(args.ext) |
|
|
|
if args.__dict__.pop('exact'): |
|
|
|
matches = s.exact(args.query) |
|
|
|
else: |
|
|
|
|