Implements #7442 by adding an option -stdin which reads additional arguments from standard in, one per line.
For example
$ echo -e "mysecretcode\n120" | src/bitcoin-cli -stdin walletpassphrase
$ echo -e "walletpassphrase\nmysecretcode\n120" | src/bitcoin-cli -stdin
$ src/bitcoin-cli -stdin walletpassphrase
mysecretcode
120
^D
This is the simplest implementation and avoids escaping issues by using newline as separator instead of space, I first had another implementation: https://github.com/laanwj/bitcoin/commit/1f73b8e27b57c8561840cddc9f69a97475d06e85 that reuses parseCommandLine from the GUI debug console, but I think this is more useful in practice as most use of cli is probably script-driven.