xmrwallet: minor arg parsing cleanup

This commit is contained in:
The MMGen Project 2025-11-15 09:50:15 +00:00
commit ddd633c6b4
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
2 changed files with 6 additions and 5 deletions

View file

@ -117,7 +117,8 @@ if cmd_args and cfg.autosign and (
if len(cmd_args) < 2:
cfg._usage()
op = cmd_args.pop(0)
usr_op = cmd_args.pop(0)
op = usr_op.replace('-', '_')
infile = cmd_args.pop(0)
wallets = spec = None
@ -135,14 +136,14 @@ match op:
if len(cmd_args) != 1:
cfg._usage()
spec = cmd_args[0]
case 'export-outputs' | 'export-outputs-sign' | 'import-key-images':
case 'export_outputs' | 'export_outputs_sign' | 'import_key_images':
if not cfg.autosign:
die(1, f'--autosign must be used with command {op!r}')
die(1, f'--autosign must be used with command {usr_op!r}')
if len(cmd_args) > 1:
cfg._usage()
wallets = cmd_args.pop(0) if cmd_args else None
case _:
die(1, f'{op!r}: unrecognized operation')
die(1, f'{usr_op!r}: unrecognized operation')
m = xmrwallet.op(op, cfg, infile, wallets, spec=spec)

View file

@ -113,4 +113,4 @@ def op_cls(op_name):
return cls
def op(op, cfg, infile, wallets, *, spec=None):
return op_cls(op.replace('-', '_'))(cfg, uargs(infile, wallets, spec))
return op_cls(op)(cfg, uargs(infile, wallets, spec))