DaemonCLI: add --conf flag

When starting a daemon with a different configuration,
the same should also be used by the cli tool.

Add the --conf flag to the cli command to allow using a
custom config file.

Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
This commit is contained in:
Antonio Quartulli 2018-01-29 16:05:11 +08:00
parent dc82c1be16
commit 34976c7602
No known key found for this signature in database
GPG key ID: 07A53C580EF2CD74
2 changed files with 23 additions and 7 deletions

View file

@ -56,6 +56,7 @@ at anytime.
* Added abandon information (claim name, id, address, amount, balance_delta and nout) about claims, supports, and updates to `transaction_list` results under `abandon_info` key
* Added `permanent_url` attribute to `channel_list_mine`, `claim_list`, `claim_show`, `resolve` and `resolve_name` API calls through lbryio/lbryum#203
*
* Added `--conf` CLI flag to lbrynet-cli tool to specify an alternative config file
### Changed
* claim_show API command no longer takes name as argument

View file

@ -38,8 +38,22 @@ def set_flag_vals(flag_names, parsed_args):
def main():
if len(sys.argv[1:]):
method, args = sys.argv[1], sys.argv[2:]
argv = sys.argv[1:]
# check if a config file has been specified. If so, shift
# all the arguments so that the parsing can continue without
# noticing
if len(argv) and argv[0] == "--conf":
if len(argv) < 2:
print_error("No config file specified for --conf option")
print_help()
return
conf.conf_file = argv[1]
argv = argv[2:]
if len(argv):
method, args = argv[0], argv[1:]
else:
print_help()
return
@ -176,13 +190,14 @@ def print_help():
" lbrynet-cli - LBRY command line client.",
"",
"USAGE",
" lbrynet-cli <command> [<args>]",
" lbrynet-cli [--conf <config file>] <command> [<args>]",
"",
"EXAMPLES",
" lbrynet-cli commands # list available commands",
" lbrynet-cli status # get daemon status",
" lbrynet-cli resolve_name what # resolve a name",
" lbrynet-cli help resolve_name # get help for a command",
" lbrynet-cli commands # list available commands",
" lbrynet-cli status # get daemon status",
" lbrynet-cli --conf ~/l1.conf status # like above but using ~/l1.conf as config file",
" lbrynet-cli resolve_name what # resolve a name",
" lbrynet-cli help resolve_name # get help for a command",
])