Better support for programatic usage of help paths.

pull/2446/head
Kieran R. Prasch 2020-11-23 11:58:05 -08:00
parent 5dae755588
commit 3e648673f6
No known key found for this signature in database
GPG Key ID: FDC3146ED25617D8
3 changed files with 23 additions and 9 deletions

View File

@ -30,14 +30,16 @@ from nucypher.cli.commands import (
worklock,
cloudworkers
)
from nucypher.cli.painting.help import echo_version, echo_config_location
from nucypher.cli.painting.help import echo_version, echo_config_root_path, echo_logging_root_path
@click.group()
@click.option('--version', help="Echo the CLI version",
is_flag=True, callback=echo_version, expose_value=False, is_eager=True)
@click.option('--config', help="Echo the configuration and log directory locations",
is_flag=True, callback=echo_config_location, expose_value=False, is_eager=True)
@click.option('--config-path', help="Echo the configuration root directory path",
is_flag=True, callback=echo_config_root_path, expose_value=False, is_eager=True)
@click.option('--logging-path', help="Echo the logging root directory path",
is_flag=True, callback=echo_logging_root_path, expose_value=False, is_eager=True)
def nucypher_cli():
"""Top level command for all things nucypher."""

View File

@ -36,11 +36,17 @@ def echo_solidity_version(ctx, param, value):
ctx.exit()
def echo_config_location(ctx, param, value):
def echo_config_root_path(ctx, param, value):
if not value or ctx.resilient_parsing:
return
click.secho(f"Configuration directory: {DEFAULT_CONFIG_ROOT}\n"
f"Logging directory: {USER_LOG_DIR}")
click.secho(DEFAULT_CONFIG_ROOT)
ctx.exit()
def echo_logging_root_path(ctx, param, value):
if not value or ctx.resilient_parsing:
return
click.secho(USER_LOG_DIR)
ctx.exit()

View File

@ -81,9 +81,15 @@ def test_echo_solidity_version(click_runner):
assert str(SOLIDITY_COMPILER_VERSION) in result.output, 'Solidity version text was not produced.'
def test_echo_config_paths(click_runner):
version_args = ('--config', )
def test_echo_config_root(click_runner):
version_args = ('--config-path', )
result = click_runner.invoke(nucypher_cli, version_args, catch_exceptions=False)
assert result.exit_code == 0
assert DEFAULT_CONFIG_ROOT in result.output, 'Configuration path text was not produced.'
def test_echo_logging_root(click_runner):
version_args = ('--logging-path', )
result = click_runner.invoke(nucypher_cli, version_args, catch_exceptions=False)
assert result.exit_code == 0
assert USER_LOG_DIR in result.output, 'Log path text was not produced.'
assert DEFAULT_CONFIG_ROOT in result.output, 'Configuration path text was not produced.'