* fix: make -h option work
This commit is contained in:
+7
-3
@@ -53,8 +53,12 @@ class PreParser(OptionParser):
|
|||||||
arg = rargs[0]
|
arg = rargs[0]
|
||||||
def option():
|
def option():
|
||||||
if not self.allow_interspersed_args and first_arg:
|
if not self.allow_interspersed_args and first_arg:
|
||||||
self.error_(('Options must precede non-option arguments'))
|
self.error(_('Options must precede non-option arguments'))
|
||||||
self.opts.append(rargs[0][2:])
|
arg = rargs[0]
|
||||||
|
if arg.startswith('--'):
|
||||||
|
self.opts.append(arg[2:])
|
||||||
|
else:
|
||||||
|
self.opts.append(arg[1:])
|
||||||
del rargs[0]
|
del rargs[0]
|
||||||
return
|
return
|
||||||
# We handle bare "--" explicitly, and bare "-" is handled by the
|
# We handle bare "--" explicitly, and bare "-" is handled by the
|
||||||
@@ -89,7 +93,7 @@ class PisiCLI(object):
|
|||||||
if 'version' in opts:
|
if 'version' in opts:
|
||||||
self.parser.print_version()
|
self.parser.print_version()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
elif 'help' in opts:
|
elif 'help' in opts or 'h' in opts:
|
||||||
self.die()
|
self.die()
|
||||||
raise Error(_('No command given'))
|
raise Error(_('No command given'))
|
||||||
cmd_name = args[0]
|
cmd_name = args[0]
|
||||||
|
|||||||
Reference in New Issue
Block a user