> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/gym/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/gym/_mcp/server.

# nemo_gym.cli.utils

## Module Contents

### Functions

| Name                                                                               | Description                                                                                             |
| ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
| [`did_you_mean`](#nemo_gym-cli-utils-did_you_mean)                                 | A ` Did you mean \`X\`?`fragment for the closest candidate to`value`, or `""\` if none is close enough. |
| [`exit_cleanly_on_config_error`](#nemo_gym-cli-utils-exit_cleanly_on_config_error) | Decorator: turn user-facing ConfigError into a clean message + non-zero exit.                           |
| [`exit_unknown_component`](#nemo_gym-cli-utils-exit_unknown_component)             | Print an `unknown &lt;type&gt; '&lt;name&gt;'` error (with a did-you-mean hint) and exit nonzero.       |
| [`fuzzy_matches`](#nemo_gym-cli-utils-fuzzy_matches)                               | Whether `query` fuzzily matches any of `fields`: a substring or a close difflib match (token-aware).    |
| [`print_no_matches`](#nemo_gym-cli-utils-print_no_matches)                         | Print the standard 'nothing to show' message for a `gym list`/`gym search` command.                     |
| [`print_rich_table`](#nemo_gym-cli-utils-print_rich_table)                         | Print a Rich table without truncating cells when standard output is piped.                              |
| [`render_component_inspection`](#nemo_gym-cli-utils-render_component_inspection)   | Render the uniform `gym list &lt;type&gt; &lt;name&gt;` inspect view (or its `--json` payload).         |

### API

```python
nemo_gym.cli.utils.did_you_mean(
    value: str,
    candidates: typing.Iterable[str]
) -> str
```

A ` Did you mean \`X\`?`fragment for the closest candidate to`value`, or `""\` if none is close enough.

```python
nemo_gym.cli.utils.exit_cleanly_on_config_error(
    fn
)
```

Decorator: turn user-facing ConfigError into a clean message + non-zero exit.

Config mistakes (missing/typo'd config\_paths, malformed config\_paths, nothing configured to
run) should fail fast with an actionable message, not a Python traceback. Unexpected errors
still propagate normally.

```python
nemo_gym.cli.utils.exit_unknown_component(
    name: str,
    candidates: typing.Iterable[str],
    type_label: str
) -> None
```

Print an `unknown &lt;type&gt; '&lt;name&gt;'` error (with a did-you-mean hint) and exit nonzero.

```python
nemo_gym.cli.utils.fuzzy_matches(
    query: str,
    fields: str = ()
) -> bool
```

Whether `query` fuzzily matches any of `fields`: a substring or a close difflib match (token-aware).

The shared matcher behind `gym search &lt;type&gt; &lt;query&gt;` across every component type.

```python
nemo_gym.cli.utils.print_no_matches(
    component_type: str,
    query: typing.Optional[str]
) -> None
```

Print the standard 'nothing to show' message for a `gym list`/`gym search` command.

`component_type` is the plural noun (`benchmarks`, `environments`, ...). Keeps the message
and styling identical across every listing.

```python
nemo_gym.cli.utils.print_rich_table(
    table
) -> None
```

Print a Rich table without truncating cells when standard output is piped.

Rich normally renders redirected output with an 80-column console.
`FORCE_COLOR` can also make Rich report a pipe as a terminal.
Use the stream's actual TTY status so redirected output preserves every cell.

```python
nemo_gym.cli.utils.render_component_inspection(
    json_output: bool,
    name: str,
    type_noun: str,
    domain: typing.Optional[str] = None,
    description: typing.Optional[str] = None,
    details: typing.Dict[str, str],
    usage: typing.Optional[str] = None
) -> None
```

Render the uniform `gym list &lt;type&gt; &lt;name&gt;` inspect view (or its `--json` payload).

`details` is an ordered label -> value mapping (e.g. `&#123;"config": ..., "agent": ...&#125;`). Text
sections (domain suffix, description, Details, Usage example) are omitted when empty.