comparison mercurial/fancyopts.py @ 164:2e87f04880ab

Make fancyopts handle no arguments This lets hg serve work with no args.
author mpm@selenic.com
date Thu, 26 May 2005 09:56:20 -0800
parents 9117c6561b0b
children 63af1db35611
comparison
equal deleted inserted replaced
163:f38c90953c2c 164:2e87f04880ab
1 import sys, os, getopt 1 import sys, os, getopt
2 2
3 def fancyopts(args, options, state, syntax=''): 3 def fancyopts(args, options, state, syntax='', minlen = 0):
4 long=[] 4 long=[]
5 short='' 5 short=''
6 map={} 6 map={}
7 dt={} 7 dt={}
8 8
16 if d: opt = opt + '(' + str(d) + ')' 16 if d: opt = opt + '(' + str(d) + ')'
17 print opt 17 print opt
18 if c: print ' %s' % c 18 if c: print ' %s' % c
19 sys.exit(0) 19 sys.exit(0)
20 20
21 if len(args) == 0: 21 if len(args) < minlen:
22 help(state, None, args) 22 help(state, None, args)
23 23
24 options=[('h', 'help', help, 'Show usage info')] + options 24 options=[('h', 'help', help, 'Show usage info')] + options
25 25
26 for s, l, d, c in options: 26 for s, l, d, c in options: