Skip to content

MkCommandOutput

Show source on GitHub

Node to display the terminal output of a command.

Example: Regular

Jinja

{{ ["hatch", "--help"] | MkCommandOutput }}

Python

MkCommandOutput(['hatch', '--help'])

hatch --help /bin/sh: 1: hatch: not found

<div data-terminal>
  <span data-ty="input">hatch --help</span>
  <span data-ty>/bin/sh: 1: hatch: not found</span>
</div>
<div data-terminal>
  <span data-ty="input">hatch --help</span>
  <span data-ty>/bin/sh: 1: hatch: not found</span>
</div>

Bases: MkTemplate

__init__

__init__(call: Sequence[str], **kwargs: Any)

Parameters:

Name Type Description Default
call Sequence[str]

System call to make

required
kwargs Any

Keyword arguments passed to parent

{}
graph TD
  94596170071968["mkcommandoutput.MkCommandOutput"]
  94596168228624["mktemplate.MkTemplate"]
  94596169139824["mkcontainer.MkContainer"]
  94596169136704["mknode.MkNode"]
  94596171773984["node.Node"]
  139930746687680["builtins.object"]
  94596168228624 --> 94596170071968
  94596169139824 --> 94596168228624
  94596169136704 --> 94596169139824
  94596171773984 --> 94596169136704
  139930746687680 --> 94596171773984
/home/runner/work/mknodes/mknodes/mknodes/templatenodes/mkcommandoutput/metadata.toml
[metadata]
icon = "mdi:bash"
name = "MkCommandOutput"

[[resources.css]]
filename = "terminal.css"

[examples.regular]
condition = "{{ 'CI' | getenv }}"
title = "Regular"
jinja = """
{{ ["hatch", "--help"] | MkCommandOutput }}
"""

[output.html]
template = """
<div data-terminal>
  <span data-ty="input">{{ node.call | join(" ") }}</span>
  <span data-ty>{{ node.call | check_output(cwd=node.cwd) }}</span>
</div>
"""
mknodes.templatenodes.mkcommandoutput.MkCommandOutput
class MkCommandOutput(mktemplate.MkTemplate):
    """Node to display the terminal output of a command."""

    ICON = "material/bash"
    STATUS = "new"
    CSS = [resources.CSSFile("terminal.css")]

    def __init__(self, call: Sequence[str], **kwargs: Any):
        """Constructor.

        Args:
            call: System call to make
            kwargs: Keyword arguments passed to parent
        """
        self.call = call
        super().__init__("output/html/template", **kwargs)

    @property
    def cwd(self):
        return self.ctx.metadata.repository_path