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 Usage: hatch [OPTIONS] COMMAND [ARGS]...

_ _ _ _ | | | | | | | | | || | __ | | ___| |__ | _ |/ ` | / | ' \ | | | | (| | || (| | | | _| |/_,|__|| ||

Options: -e, --env TEXT The name of the environment to use [env var: HATCH_ENV] -p, --project TEXT The name of the project to work on [env var: HATCH_PROJECT] --color / --no-color Whether or not to display colored output (default is auto-detection) [env vars: FORCE_COLOR/NO_COLOR] --interactive / --no-interactive Whether or not to allow features like prompts and progress bars (default is auto- detection) [env var: HATCH_INTERACTIVE] -v, --verbose Increase verbosity (can be used additively) [env var: HATCH_VERBOSE] -q, --quiet Decrease verbosity (can be used additively) [env var: HATCH_QUIET] --data-dir TEXT The path to a custom directory used to persist data [env var: HATCH_DATA_DIR] --cache-dir TEXT The path to a custom directory used to cache data [env var: HATCH_CACHE_DIR] --config TEXT The path to a custom config file to use [env var: HATCH_CONFIG] --version Show the version and exit. -h, --help Show this message and exit.

Commands: build Build a project clean Remove build artifacts config Manage the config file dep Manage environment dependencies env Manage project environments new Create or initialize a project project View project information publish Publish build artifacts run Run commands within project environments shell Enter a shell within a project's environment status Show information about the current environment version View or set a project's version

<div data-terminal>
  <span data-ty="input">hatch --help</span>
  <span data-ty>Usage: hatch [OPTIONS] COMMAND [ARGS]...

   _   _       _       _
  | | | |     | |     | |
  | |_| | __ _| |_ ___| |__
  |  _  |/ _` | __/ __| '_ \
  | | | | (_| | || (__| | | |
  \_| |_/\__,_|\__\___|_| |_|

Options:
  -e, --env TEXT                  The name of the environment to use [env var:
                                  `HATCH_ENV`]
  -p, --project TEXT              The name of the project to work on [env var:
                                  `HATCH_PROJECT`]
  --color / --no-color            Whether or not to display colored output
                                  (default is auto-detection) [env vars:
                                  `FORCE_COLOR`/`NO_COLOR`]
  --interactive / --no-interactive
                                  Whether or not to allow features like
                                  prompts and progress bars (default is auto-
                                  detection) [env var: `HATCH_INTERACTIVE`]
  -v, --verbose                   Increase verbosity (can be used additively)
                                  [env var: `HATCH_VERBOSE`]
  -q, --quiet                     Decrease verbosity (can be used additively)
                                  [env var: `HATCH_QUIET`]
  --data-dir TEXT                 The path to a custom directory used to
                                  persist data [env var: `HATCH_DATA_DIR`]
  --cache-dir TEXT                The path to a custom directory used to cache
                                  data [env var: `HATCH_CACHE_DIR`]
  --config TEXT                   The path to a custom config file to use [env
                                  var: `HATCH_CONFIG`]
  --version                       Show the version and exit.
  -h, --help                      Show this message and exit.

Commands:
  build    Build a project
  clean    Remove build artifacts
  config   Manage the config file
  dep      Manage environment dependencies
  env      Manage project environments
  new      Create or initialize a project
  project  View project information
  publish  Publish build artifacts
  run      Run commands within project environments
  shell    Enter a shell within a project's environment
  status   Show information about the current environment
  version  View or set a project's version
</span>
</div>
<div data-terminal>
  <span data-ty="input">hatch --help</span>
  <span data-ty>Usage: hatch [OPTIONS] COMMAND [ARGS]...

   _   _       _       _
  | | | |     | |     | |
  | |_| | __ _| |_ ___| |__
  |  _  |/ _` | __/ __| '_ \
  | | | | (_| | || (__| | | |
  \_| |_/\__,_|\__\___|_| |_|

Options:
  -e, --env TEXT                  The name of the environment to use [env var:
                                  `HATCH_ENV`]
  -p, --project TEXT              The name of the project to work on [env var:
                                  `HATCH_PROJECT`]
  --color / --no-color            Whether or not to display colored output
                                  (default is auto-detection) [env vars:
                                  `FORCE_COLOR`/`NO_COLOR`]
  --interactive / --no-interactive
                                  Whether or not to allow features like
                                  prompts and progress bars (default is auto-
                                  detection) [env var: `HATCH_INTERACTIVE`]
  -v, --verbose                   Increase verbosity (can be used additively)
                                  [env var: `HATCH_VERBOSE`]
  -q, --quiet                     Decrease verbosity (can be used additively)
                                  [env var: `HATCH_QUIET`]
  --data-dir TEXT                 The path to a custom directory used to
                                  persist data [env var: `HATCH_DATA_DIR`]
  --cache-dir TEXT                The path to a custom directory used to cache
                                  data [env var: `HATCH_CACHE_DIR`]
  --config TEXT                   The path to a custom config file to use [env
                                  var: `HATCH_CONFIG`]
  --version                       Show the version and exit.
  -h, --help                      Show this message and exit.

Commands:
  build    Build a project
  clean    Remove build artifacts
  config   Manage the config file
  dep      Manage environment dependencies
  env      Manage project environments
  new      Create or initialize a project
  project  View project information
  publish  Publish build artifacts
  run      Run commands within project environments
  shell    Enter a shell within a project's environment
  status   Show information about the current environment
  version  View or set a project's version
</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
  94854583242048["mkcommandoutput.MkCommandOutput"]
  94854582782240["mktemplate.MkTemplate"]
  94854582919984["mkcontainer.MkContainer"]
  94854582916880["mknode.MkNode"]
  94854582838576["node.Node"]
  140544995341632["builtins.object"]
  94854582782240 --> 94854583242048
  94854582919984 --> 94854582782240
  94854582916880 --> 94854582919984
  94854582838576 --> 94854582916880
  140544995341632 --> 94854582838576
/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.

        Arguments:
            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