Skip to content

Commit

Permalink
minor plugin cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
mplsgrant committed Nov 22, 2024
1 parent 914ec70 commit 89a3f29
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/warnet/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def toggle(plugin: str):
@click.argument("plugin_name", type=str, default="")
@click.argument("function_name", type=str, default="")
@click.option(
"--params", type=str, default="", help="Paramter data to be fed to the plugin function"
"--params", type=str, default="", help="Parameter data to be fed to the plugin function"
)
def run(plugin_name: str, function_name: str, params: str):
"""Explore and run plugins
Expand Down Expand Up @@ -206,7 +206,7 @@ def run(plugin_name: str, function_name: str, params: str):
)
else:
click.secho(
f"\nwarnet plugin run {plugin_name} {function_name} --json-input '{json.dumps(params)}'",
f"\nwarnet plugin run {plugin_name} {function_name} --params '{json.dumps(params)}'",
fg="green",
)
else:
Expand All @@ -221,17 +221,15 @@ def execute_function_with_params(func: Callable[..., Any], params: dict | list):
try:
return_value = func(**params)
if return_value is not None:
jsonified = json.dumps(return_value)
print(f"'{jsonified}'")
print(json.dumps(return_value))
except Exception as e:
click.secho(f"Exception: {e}", fg="yellow")
sys.exit(1)
case list():
try:
return_value = func(*params)
if return_value is not None:
jsonified = json.dumps(return_value)
print(f"'{jsonified}'")
print(json.dumps(return_value))
except Exception as e:
click.secho(f"Exception: {e}", fg="yellow")
sys.exit(1)
Expand Down

0 comments on commit 89a3f29

Please sign in to comment.