Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cvs/cli_plugins/base.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import sys


class SubcommandPlugin:
"""Base class for CLI subcommand plugins."""

Expand All @@ -6,6 +9,10 @@ class SubcommandPlugin:
"exec": 1000, # High number to ensure exec appears last
}

def _emit_error(self, msg, json_mode):
"""Print an error message. In JSON mode, writes to stderr so stdout stays valid JSON."""
print(msg, file=sys.stderr if json_mode else sys.stdout)

def get_name(self):
raise NotImplementedError

Expand Down
4 changes: 0 additions & 4 deletions cvs/cli_plugins/exec_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,6 @@ def _run_on_hosts(

return True, output

def _emit_error(self, msg, json_mode):
"""Print an error message. In JSON mode, writes to stderr so stdout stays valid JSON."""
print(msg, file=sys.stderr if json_mode else sys.stdout)

def _print_text_output(self, label, host_output):
"""Print host results in human-readable format."""
for host, out in host_output.items():
Expand Down