summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAssaf Gordon <assafgordon@gmail.com>2016-02-26 16:17:49 (GMT)
committerAssaf Gordon <assafgordon@gmail.com>2016-02-26 16:17:49 (GMT)
commit2193040c363f989ca6f70f1d3ef4c6089a3ab237 (patch)
tree0a3a97ebbd17da72f697938e12a2e029cb86a802
parent457d9fc2cf634ad53d2b966035f41561b163afda (diff)
downloadcode-snippets-2193040c363f989ca6f70f1d3ef4c6089a3ab237.zip
code-snippets-2193040c363f989ca6f70f1d3ef4c6089a3ab237.tar.gz
code-snippets-2193040c363f989ca6f70f1d3ef4c6089a3ab237.tar.bz2
skeleton.py: add '--feature' support, metadata description
-rw-r--r--metadata.yml2
-rwxr-xr-xskeleton.py8
2 files changed, 10 insertions, 0 deletions
diff --git a/metadata.yml b/metadata.yml
index a0c9592..87d6d96 100644
--- a/metadata.yml
+++ b/metadata.yml
@@ -1,6 +1,8 @@
files:
skeleton.sh:
description: 'Shell script skeleton with getops and help screen'
+ skeleton.py:
+ description: 'Python script skeleton with argparse and help screen'
git-post-update-jekyll-hook:
description: 'Rebuild a jekyll static website on git-push (similar to github pages)'
links:
diff --git a/skeleton.py b/skeleton.py
index cfee063..b4220c7 100755
--- a/skeleton.py
+++ b/skeleton.py
@@ -28,6 +28,14 @@ Example:
parser.add_argument("-V", "--verbose", help="be verbose",
action="store_true")
+ # an on/off feature, default 'on'.
+ parser.add_argument('--feature', dest='feature', action='store_true',
+ help="enable feature (default)")
+ parser.add_argument('--no-feature', dest='feature', action='store_false',
+ help="disable feature")
+ parser.set_defaults(feature=True)
+
+
# Positional parameter
parser.add_argument('filename', metavar='FILE', help='file to process');
args = parser.parse_args()