Metadata-Version: 2.4
Name: rsi-varlog-explorer
Version: 1.6.4
Summary: Junos RSI and varlog explorer with interactive CLI simulator
Author: Ying Wang
License: MIT
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Networking
Requires-Python: >=3.8
Requires-Dist: httpx
Requires-Dist: prompt-toolkit>=3.0.0
Requires-Dist: pyparsing>=3.1.4
Requires-Dist: pyyaml>=5.4
Provides-Extra: dev
Requires-Dist: mypy>=1.0.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
Requires-Dist: pytest>=7.0.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Provides-Extra: junos
Requires-Dist: junos-eznc>=2.6.0; extra == 'junos'
Description-Content-Type: text/markdown

# rsi-varlog-explorer

An interactive tool for navigating Junos RSI output and var/log files through a simulated Junos CLI environment.

## Features

- Interactive Junos CLI simulation for RSI and var/log exploration
- Auto-detects RSI files and var/log sources
- Automatically extracts case archives
- Handles single-RE and dual-RE var/log inputs
- Supports operational and configuration mode navigation (`configure`, `edit`, `top`, `up`, `exit`)
- Supports Junos-style `?` help
- Supports command completion and shorthand expansion with `Tab` or `Space`
- Supports partial commands and common abbreviations, such as `show int ter`
- Supports pipe processing: `match`, `grep`, `except`, `find`, `last`, `count`, `trim`, `no-more`, `save`, `display set`
- Supports pager control with `--no-pager`, `pager on/off`, and `Ctrl+C`

## Installation

```bash
pip install rsi-varlog-explorer
```

Verify the command:

```bash
rsi-varlog --version
```

## Basic Usage

Analyze a local case directory:

```bash
rsi-varlog /path/to/case-directory
```

Analyze a direct RSI file:

```bash
rsi-varlog /path/to/device-rsi.log
```

Specify the RSI file or var/log directory explicitly:

```bash
rsi-varlog /path/to/case-directory --rsi-file device-rsi.log
rsi-varlog /path/to/case-directory --var-log-dir /path/to/var-log-dir
rsi-varlog /path/to/case-directory --var-log-dir /path/to/re0/var-log-dir /path/to/re1/var-log-dir
```

## Read-Only Case Directories

If the input case directory is read-only, the tool can stage a writable copy before extracting archives.

Use `--work-dir` to provide a writable root directory. The tool creates a subdirectory named after the case directory:

```bash
rsi-varlog /readonly/path/to/case-123 --work-dir /writable/path/to/work
```

This analyzes:

```text
/writable/path/to/work/case-123
```

You can also configure this once with an environment variable:

```bash
export RSI_VARLOG_WORK_ROOT=/writable/path/to/work
rsi-varlog /readonly/path/to/case-123
```

For multi-user systems, use a template with `{user}`:

```bash
export RSI_VARLOG_WORK_ROOT_TEMPLATE="/writable/path/{user}/case"
rsi-varlog /readonly/path/to/case-123
```

If no work directory is configured and the input case directory is read-only, the tool stages files under:

```text
~/.cache/rsi-varlog-explorer/case/<case-directory-name>
```

Refresh an existing staged copy:

```bash
rsi-varlog /readonly/path/to/case-123 --refresh-stage
```

## Archive Extraction

By default, archives are extracted in the effective case directory. For read-only inputs this is the staged copy.

You can redirect archive extraction explicitly:

```bash
rsi-varlog /path/to/case-directory --extract-dir /path/to/extract-dir
```

## Interactive Commands

Examples inside the simulator:

```text
show version
show log ?
show log messages | match error
show chassis hardware detail no-forwarding
show interfaces terse | match ge-
show configuration | display set
show configuration protocols bgp
quit
```

Press `?` for contextual help. Press `Ctrl+C` to stop paging, and press `Ctrl+C` again to exit.

## CLI Options

```text
rsi-varlog <case-directory-or-rsi-file>
rsi-varlog <case-directory> --no-pager
rsi-varlog <case-directory> --extract-dir <dir>
rsi-varlog <case-directory> --work-dir <writable-root>
rsi-varlog <case-directory> --refresh-stage
rsi-varlog <case-directory> --rsi-file <path>
rsi-varlog <case-directory> --var-log-dir <dir>
rsi-varlog <case-directory> --var-log-dir <re0-dir> <re1-dir>
```

## Development

```bash
python -m pip install -U build twine pytest
python -m pytest
python -m build
python -m twine check dist/*
```

## Publishing Checklist

Before publishing to a public package index:

1. Build a clean distribution.
2. Inspect wheel and sdist contents.
3. Scan for private hostnames, internal domains, internal paths, real customer case identifiers, credentials, tokens, and personal usernames.
4. Run `twine check dist/*`.

## License

MIT
