annotate mozillahg/main.py @ 0:1855ba0b873a

initial commit
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 22 Jan 2013 21:30:20 -0800
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
1855ba0b873a initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 #!/usr/bin/env python
1855ba0b873a initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2
1855ba0b873a initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3 """
1855ba0b873a initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4 mozilla interface to mercurial
1855ba0b873a initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5 """
1855ba0b873a initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
6
1855ba0b873a initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
7 import sys
1855ba0b873a initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
8 import optparse
1855ba0b873a initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
9
1855ba0b873a initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
10 def main(args=sys.argv[:]):
1855ba0b873a initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
11
1855ba0b873a initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
12 # parse command line options
1855ba0b873a initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
13 usage = '%prog [options]'
1855ba0b873a initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
14 class PlainDescriptionFormatter(optparse.IndentedHelpFormatter):
1855ba0b873a initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
15 """description formatter for console script entry point"""
1855ba0b873a initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
16 def format_description(self, description):
1855ba0b873a initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
17 if description:
1855ba0b873a initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
18 return description.strip() + '\n'
1855ba0b873a initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
19 else:
1855ba0b873a initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
20 return ''
1855ba0b873a initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
21 parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter())
1855ba0b873a initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
22 options, args = parser.parse_args(args)
1855ba0b873a initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
23
1855ba0b873a initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
24 if __name__ == '__main__':
1855ba0b873a initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
25 main()
1855ba0b873a initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
26