mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -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:
|
||||
parser.print_help()
|
||||
return 1
|
||||
cmd = args[1]
|
||||
if cmd not in COMMANDS:
|
||||
if cmd == '--version':
|
||||
parser.print_version()
|
||||
return 0
|
||||
if args[1] == '--version':
|
||||
parser.print_version()
|
||||
return 0
|
||||
for i, x in enumerate(args):
|
||||
if i > 0 and x in COMMANDS:
|
||||
cmd = x
|
||||
break
|
||||
else:
|
||||
parser.print_help()
|
||||
return 1
|
||||
|
||||
del args[i]
|
||||
parser = option_parser_for(cmd)()
|
||||
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__':
|
||||
|
Loading…
x
Reference in New Issue
Block a user