cli: implement new 'flattened JSON' mode.

Much nicer for grepping, since `{ "foo": { "bar": [7] } }` is turned into
`foo.bar[0]=7`.

Changelog-Added: cli: New `--flat` mode for easy grepping.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2020-05-11 10:33:09 +09:30
committed by Christian Decker
parent 679d3494b4
commit abb16b4226
2 changed files with 66 additions and 0 deletions

View File

@@ -1063,6 +1063,17 @@ def test_cli(node_factory):
assert [l for l in lines if l.startswith('help=')] == []
assert [l for l in lines if l.startswith('format-hint=')] == []
# Flat format is great for grep. LONG LIVE UNIX!
out = subprocess.check_output(['cli/lightning-cli',
'--network={}'.format(TEST_NETWORK),
'--lightning-dir={}'
.format(l1.daemon.lightning_dir),
'-F',
'help']).decode('utf-8')
lines = out.splitlines()
# Everything is a help[XX]= line, except format-hint.
assert [l for l in lines if not re.search(r'^help\[[0-9]*\].', l)] == ['format-hint=simple']
def test_daemon_option(node_factory):
"""