mirror of
https://github.com/wting/autojump
synced 2025-06-07 09:54:06 +00:00
handle empty input
This commit is contained in:
parent
4aafd023c3
commit
d20ec4afb4
14
bin/autojump
14
bin/autojump
@ -314,9 +314,8 @@ def print_stats(data, data_path):
|
|||||||
print("\ndata:\t %s" % data_path)
|
print("\ndata:\t %s" % data_path)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main(args):
|
||||||
config = set_defaults()
|
config = set_defaults()
|
||||||
args = parse_arguments()
|
|
||||||
|
|
||||||
if args.add:
|
if args.add:
|
||||||
save(config, first(add_path(load(config), args.add)))
|
save(config, first(add_path(load(config), args.add)))
|
||||||
@ -342,7 +341,10 @@ def main():
|
|||||||
elif args.stat:
|
elif args.stat:
|
||||||
print_stats(load(config), config['data_path'])
|
print_stats(load(config), config['data_path'])
|
||||||
else:
|
else:
|
||||||
# no optional arguments
|
if not args.directory:
|
||||||
|
print(encode_local('.'))
|
||||||
|
return 0
|
||||||
|
|
||||||
entries = entriefy(load(config))
|
entries = entriefy(load(config))
|
||||||
needles = sanitize(args.directory)
|
needles = sanitize(args.directory)
|
||||||
needle = first(needles)
|
needle = first(needles)
|
||||||
@ -370,12 +372,12 @@ def main():
|
|||||||
print(encode_local(surround_quotes(
|
print(encode_local(surround_quotes(
|
||||||
first(find_matches(entries, needles)).path)))
|
first(find_matches(entries, needles)).path)))
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
# always return something so the calling shell function has an
|
# no results, always return something so the calling shell
|
||||||
# argument to `cd` to
|
# function has an argument to `cd` to
|
||||||
print(encode_local('.'))
|
print(encode_local('.'))
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
sys.exit(main())
|
sys.exit(main(parse_arguments()))
|
||||||
|
Loading…
Reference in New Issue
Block a user