Skip to content

Instantly share code, notes, and snippets.

@nopjia
Created September 29, 2014 22:48
Show Gist options
  • Save nopjia/73d997fca77237d59399 to your computer and use it in GitHub Desktop.
Save nopjia/73d997fca77237d59399 to your computer and use it in GitHub Desktop.
Python Command-line
#!/usr/bin/python
import os, sys
def main():
# Command-line Processor
cmd_dir, cmd_name = os.path.split(os.path.abspath(sys.argv[0]))
cmd_args = sys.argv[1:]
print "Working Dir:\t" + cmd_dir
print "Command Name:\t" + cmd_name
if len(cmd_args):
print "Received %s Arguments:" % (len(sys.argv)-1)
for s in sys.argv[1:]:
print s
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment