summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAssaf Gordon <assafgordon@gmail.com>2016-02-23 17:15:55 (GMT)
committerAssaf Gordon <assafgordon@gmail.com>2016-02-23 17:15:55 (GMT)
commit457d9fc2cf634ad53d2b966035f41561b163afda (patch)
treec01983504129c5da3d4444e487a521fd955ce3b3
parenta888f2e3dfaf2257d868f489bc9d5a6e087056cf (diff)
downloadcode-snippets-457d9fc2cf634ad53d2b966035f41561b163afda.zip
code-snippets-457d9fc2cf634ad53d2b966035f41561b163afda.tar.gz
code-snippets-457d9fc2cf634ad53d2b966035f41561b163afda.tar.bz2
skeleton.py: new template for python scripts
-rwxr-xr-xskeleton.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/skeleton.py b/skeleton.py
new file mode 100755
index 0000000..cfee063
--- /dev/null
+++ b/skeleton.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+import sys,argparse
+
+version_info=\
+"""
+Frobnicator - version 0.1
+Copyright (C) 2016 Assaf Gordon <assafgordon@gmail.com>
+License: MIT
+"""
+
+def parse_command_line():
+ # Define parameters
+ parser = argparse.ArgumentParser(
+ formatter_class=argparse.RawDescriptionHelpFormatter,
+ description="This is a frobnicator",
+ version=version_info,
+ epilog="""
+
+This script frobnicates an input file.
+Example:
+
+ $ %(prog)s -v FOO
+
+ """)
+
+
+ # Option parameters
+ parser.add_argument("-V", "--verbose", help="be verbose",
+ action="store_true")
+
+ # Positional parameter
+ parser.add_argument('filename', metavar='FILE', help='file to process');
+ args = parser.parse_args()
+
+ return args
+
+
+if __name__ == "__main__":
+ args = parse_command_line()
+
+ if args.verbose:
+ print "File to process:", args.filename