Skip to content

Instantly share code, notes, and snippets.

@jbradforddillon
Last active August 29, 2015 13:57
Show Gist options
  • Save jbradforddillon/9883753 to your computer and use it in GitHub Desktop.
Save jbradforddillon/9883753 to your computer and use it in GitHub Desktop.
Super simple implementation stubber. Point it at a .h file.
#!/usr/bin/env python
import sys
f = open(sys.argv[1])
output = ""
for line in f:
if line[0:10] == "@interface":
colonIndex = line.find(":")
implLine = line
if colonIndex is not -1:
implLine = line[0:colonIndex]
output += implLine.replace("@interface", "@implementation").strip()
output += "\n"
if line[0] in ("-", "+"):
output += "\n"
impLine = line.replace(";", "")
output += impLine
output += "{\n\n}\n\n"
if line[0:4] == "@end":
output += "@end"
print output
# Usage
# $ python ./stubby.py /path/to/objc/Class.h
# For copy/paste, pipe it to pbcopy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment