Skip to content

Instantly share code, notes, and snippets.

@RaminNietzsche
Created May 7, 2014 08:38
Show Gist options
  • Save RaminNietzsche/2a031f55ea4dafe22b37 to your computer and use it in GitHub Desktop.
Save RaminNietzsche/2a031f55ea4dafe22b37 to your computer and use it in GitHub Desktop.
import getopt, sys
VERSION = 0.1
def help():
print '-h for help\n-v for version\n-p <str> or --print <str> for print string'
def main(argv):
try:
# hvp:
# -h ro bekho0n
# -v ro bekho0n
# -p ro bekho0n ba voro0di badiee
# print=
# --print ro bekho0n ba voro0di badiee
opts, args = getopt.getopt(argv,"hvp:",["print="])
except:
pass
for arg, value in opts:
if arg == '-v':
print VERSION
exit(0)
elif arg == '-h':
help()
exit(0)
elif arg in ('-p', '--print'):
print value
if __name__ == "__main__":
main(sys.argv[1:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment