helpme: Wrap response in simple format-hint, so lightning-cli prints it as -H

This commit is contained in:
Simon Vrouwe
2019-07-30 11:44:10 +03:00
committed by Christian Decker
parent 5a0a3a215f
commit 9e25aad3d1

View File

@@ -1,6 +1,7 @@
#! /usr/bin/env python3 #! /usr/bin/env python3
from lightning import Plugin, Millisatoshi, RpcError from lightning import Plugin, Millisatoshi, RpcError
from collections import defaultdict from collections import defaultdict
from functools import wraps
from os import path from os import path
import random import random
import threading import threading
@@ -896,7 +897,16 @@ Rusty Russell,
Senior Code Monkey.""" Senior Code Monkey."""
# Format hint `simple` makes lightning-cli print it as (-H) human readable
def format_simple(fn):
@wraps(fn)
def wrapped(*args, **kwargs):
return {'text': fn(*args, **kwargs), 'format-hint': 'simple'}
return wrapped
@plugin.method("helpme") @plugin.method("helpme")
@format_simple
def helpme(plugin, command=None, *args): def helpme(plugin, command=None, *args):
"""Gives helpful hints about running this node.""" """Gives helpful hints about running this node."""