added unique and first modifiers to lookup subcommand
parent
f592f2808a
commit
e826c31048
12
filetags.py
12
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))
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue