mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
calibredb: Allow specifying global options before the command
This commit is contained in:
parent
6782fde633
commit
1f1fe6b024
@ -228,17 +228,20 @@ def main(args=sys.argv):
|
|||||||
if len(args) < 2:
|
if len(args) < 2:
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
return 1
|
return 1
|
||||||
cmd = args[1]
|
if args[1] == '--version':
|
||||||
if cmd not in COMMANDS:
|
parser.print_version()
|
||||||
if cmd == '--version':
|
return 0
|
||||||
parser.print_version()
|
for i, x in enumerate(args):
|
||||||
return 0
|
if i > 0 and x in COMMANDS:
|
||||||
|
cmd = x
|
||||||
|
break
|
||||||
|
else:
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
return 1
|
return 1
|
||||||
|
del args[i]
|
||||||
parser = option_parser_for(cmd)()
|
parser = option_parser_for(cmd)()
|
||||||
opts, args = parser.parse_args(args)
|
opts, args = parser.parse_args(args)
|
||||||
return run_cmd(cmd, opts, args[2:], DBCtx(opts))
|
return run_cmd(cmd, opts, args[1:], DBCtx(opts))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user