Commits

Takafumi Arakaki committed ccc41ac

Improve command help

Comments (0)

Files changed (2)

                [{wiki,w,changesets,c,new_issue,n,admin,m,annotate,a,download,d,src,s,issue,i}]
                [file]
 
-Open relevant page in Bitbucket
+Open relevant page in Bitbucket.
+
+This command works for both Git and Mercurial project.
+
+Examples
+--------
+
+Open top page in Bitbucket::
+
+    bitb.py
+
+Open blame/annotation page of a given file::
+
+    bitb.py annotate FILE
+
+View source code in bitbucket::
+
+    bitb.py src FILE
+
+View issues page::
+
+    bitb.py issue
+
+Create a new issue::
+
+    bitb.py new_issue
 
 positional arguments:
   {wiki,w,changesets,c,new_issue,n,admin,m,annotate,a,download,d,src,s,issue,i}
-                        page to go
-  file                  relevant file
+                        page to go (default: None)
+  file                  relevant file (default: None)
 
 optional arguments:
   -h, --help            show this help message and exit
 #!/usr/bin/env python
 
-"""Open relevant page in Bitbucket"""
+"""
+Open relevant page in Bitbucket.
+
+This command works for both Git and Mercurial project.
+
+Examples
+--------
+
+Open top page in Bitbucket::
+
+    %(prog)s
+
+Open blame/annotation page of a given file::
+
+    %(prog)s annotate FILE
+
+View source code in bitbucket::
+
+    %(prog)s src FILE
+
+View issues page::
+
+    %(prog)s issue
+
+Create a new issue::
+
+    %(prog)s new_issue
+
+"""
 
 # the original idea is from here:
 #   http://hgtip.com/tips/advanced/2009-10-08-open-bitbucket-from-bash/
 
 
 def main():
-    from argparse import ArgumentParser
-    parser = ArgumentParser(description=__doc__)
+    import argparse
+
+    class Formatter(argparse.RawTextHelpFormatter,
+                    argparse.RawDescriptionHelpFormatter,
+                    argparse.ArgumentDefaultsHelpFormatter):
+        pass
+
+    parser = argparse.ArgumentParser(
+        description=__doc__,
+        formatter_class=Formatter,
+    )
     parser.add_argument(
         'goto', choices=list(choices()), nargs='?',
         help="page to go")