diff --git a/filetags.py b/filetags.py index 6bb26f1..322cac7 100644 --- a/filetags.py +++ b/filetags.py @@ -389,7 +389,17 @@ if __name__ == "__main__": for file_hash in common_file_hashes: lookup_results[file_hash] = get_tags_by_hash(storage_directory, file_hash) - print(json.dumps(lookup_results)) + if 'unique' in command: + if(len(lookup_results)==1): + print(json.dumps(lookup_results)) + else: + print("More than one matching file found.", file=sys.stderr) + sys.exit(GENERAL_ERROR) + elif 'first' in command: + file_hash, tags = list(lookup_results.items())[0] + print(json.dumps({file_hash : tags})) + else: + print(json.dumps(lookup_results))