Hey! The plugin docs mention something about <stre...
# plugins
f
Hey! The plugin docs mention something about streaming output, but there's not a lot there. Is there a way to do that in our own rules?
w
yea, that could use some love.
the way this is accomplished is by implementing the
EngineAwareReturnType
interface for the return value of a `@rule`: in particular, the
message
and
level
methods: https://github.com/pantsbuild/pants/blob/1aaa97b28f46aee504badf96ea3fc6481ec9986b/src/python/pants/engine/engine_aware.py#L39-L64
f
ah... so if you want to show a process output, you'd do something like:
Copy code
@dataclass(frozen=True)
class ShowProcessResult(EngineAwareReturnType):
    result: ProcessResult

    def message(self):
        return some_transformation_on(self.result.stdout, self.result.stderr)

@rule
def show_process_result(process: Process) -> ShowProcessResult:
    result = await Get(ProcessResult, Process, process)
    return ShowProcessResult(result)
where
some_transformation_on()
is implied to be some function that makes the output of this process suitable for displaying back to the user