Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmdline: add listconfig/helpconfig #9034

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions electrum/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,17 @@ async def setconfig(self, key, value):
cv = self.config.cv.from_key(key)
cv.set(value)

@command('')
async def listconfig(self):
"""Returns the list of all configuration variables. """
return self.config.list_config_vars()

@command('')
async def helpconfig(self, key, more=False):
"""Returns help about a configuration variable. """
cv = self.config.cv.from_key(key)
return cv.get_long_desc() if more else cv.get_short_desc()
Comment on lines +361 to +364
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure we need the --more option. How about combining the two descriptions?
e.g.:

Suggested change
async def helpconfig(self, key, more=False):
"""Returns help about a configuration variable. """
cv = self.config.cv.from_key(key)
return cv.get_long_desc() if more else cv.get_short_desc()
async def helpconfig(self, key):
"""Returns help about a configuration variable. """
cv = self.config.cv.from_key(key)
short = cv.get_short_desc()
long = cv.get_long_desc()
if short and long:
return short + "\n---\n\n" + long
else:
return short or long


@command('')
async def make_seed(self, nbits=None, language=None, seed_type=None):
"""Create a seed"""
Expand Down Expand Up @@ -1471,6 +1482,7 @@ def eval_bool(x: str) -> bool:
'to_ccy': (None, "Currency to convert to"),
'unlock': (None, "Unlock the wallet (store the password in memory)."),
'public': (None, 'Channel will be announced'),
'more': (None, 'Return detailed description'),
}


Expand Down
3 changes: 3 additions & 0 deletions electrum/simple_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ def __init__(self, options=None, read_user_config_function=None,
self.amt_precision_post_satoshi = self.BTC_AMOUNTS_PREC_POST_SAT
self.amt_add_thousands_sep = self.BTC_AMOUNTS_ADD_THOUSANDS_SEP

def list_config_vars(self) -> Sequence[str]:
return list(sorted(_config_var_from_key.keys()))

def electrum_path_root(self):
# Read electrum_path from command line
# Otherwise use the user's default data directory.
Expand Down