HomePhabricator

rpc: Allow named and positional arguments to be used together

Description

rpc: Allow named and positional arguments to be used together

Summary:

It's nice to be able to use named options and positional arguments together.

Most shell tools accept both, and python functions combine options and
arguments allowing them to be passed with even more flexibility. This change
adds support for python's approach so as a motivating example:

    bitcoin-cli -named createwallet wallet_name=mywallet load_on_startup=1

Can be shortened to:

    bitcoin-cli -named createwallet mywallet load_on_startup=1

JSON-RPC standard doesn't have a convention for passing named and positional
parameters together, so this implementation makes one up and interprets any
unused "args" named parameter as a positional parameter array.

Backport of core#19762.

Depends on D16240.

Test Plan:

ninja all check-all

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Differential Revision: https://reviews.bitcoinabc.org/D16241

Details

Provenance
FabienAuthored on May 29 2024, 09:12
FabienPushed on May 29 2024, 11:49
Reviewer
Restricted Project
Differential Revision
D16241: rpc: Allow named and positional arguments to be used together
Parents
rABC964a62339ca3: Bump version to 0.29.6
Branches
Unknown
Tags
Unknown