Skip to content

Instantly share code, notes, and snippets.

@DoWhileGeek
Created January 12, 2016 07:29
Show Gist options
  • Save DoWhileGeek/b41bded95e9a5057307e to your computer and use it in GitHub Desktop.
Save DoWhileGeek/b41bded95e9a5057307e to your computer and use it in GitHub Desktop.
A handy command line app for quickly generating uuids.
#!/usr/bin/env python3
from uuid import uuid4
import argparse
import pyperclip
def parse():
parser = argparse.ArgumentParser()
parser.add_argument("-c", "--clipboard", action="store_true", help="store contents in system clipboard")
parser.add_argument("-v", "--verbose", action="store_true", help="print uuid pasted to clipboard, if the flag is set")
args = parser.parse_args()
return vars(args)
def main():
args = parse()
uuid = str(uuid4())
if args["clipboard"]:
pyperclip.copy(uuid)
if args["verbose"]:
print("{} copied to clipboard".format(uuid))
else:
print(uuid)
if __name__ == "__main__":
main()
@yani-
Copy link

yani- commented Jan 13, 2016

being a bash person, I'll probably go for something like: uuidgen | pbcopy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment