Metadata-Version: 2.4
Name: rsi-explorer-jtac
Version: 1.5.2
Summary: RSI (Request Support Information) parser and Junos CLI simulator
Project-URL: Homepage, https://github.hpe.com/ying-wang/RSI-Explorer-JTAC
Project-URL: Repository, https://github.hpe.com/ying-wang/RSI-Explorer-JTAC
Project-URL: Issues, https://github.hpe.com/ying-wang/RSI-Explorer-JTAC/issues
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-explorer-JTAC

A Juniper RSI (Request Support Information) parser and interactive Junos CLI simulator. Load an RSI file and explore its contents as if you were on the actual device, with tab completion, pipe commands, and contextual help.

This customized version is optimized for the JTAC daily workflow and introduces features that make the simulator experience much closer to a real Junos CLI:

- **Spacebar Completion**: Supports shortcut expansion (for example, typing `sh cha har` and pressing Space expands to `show chassis hardware`).
- **Contextual Help (`?`)**: Type `?` at any point to list available sub-commands (for example, `show chassis ?`).
- **Enhanced Config Mode**: Supports full hierarchical navigation, including `configure`, `edit`, and `show` within specific hierarchy levels.
- **Smart Output Filtering**: Automatically omits `no-forwarding` statements (for example, in `show chassis hardware`) for a cleaner view of auto-matched components.
- **Improved Pager Control**: Press `Ctrl+C` once to stop the pager and return to the CLI prompt. Press `Ctrl+C` a second time to exit the tool.

[![RSI CLI Demo](https://i.imgur.com/hWe8trh.gif)](https://github.hpe.com/ying-wang/rsi-explorer-JTAC/raw/main/docs/media/Untitled_hq.mp4)

## Getting Started (New Users)

### Prerequisites

- Read/write permission on the case directory — required for automatic subfolder creation and archive extraction on first run
- **One device per case directory** — if a path contains RSI files or varlog archives for more than one device, move them into separate subdirectories before running the tool (e.g. `case/device-A/` and `case/device-B/`), otherwise the tool may mix up RSI data across devices
- SSH access to `p-jtac-lnx02`

On `p-jtac-lnx02`, verify Python 3.8+ is available:

```bash
ssh <your_username>@p-jtac-lnx02
python3 --version
```

If you see Python 3.8+, you're all set. If not, pyenv is available — see Optional Setup below.

### Installation

Login to `p-jtac-lnx02` and install (one-time only):

```bash
# Step 1: SSH into the JTAC server
ssh <your_username>@p-jtac-lnx02

# Step 2: Install the tool
pip install rsi-explorer-jtac --user

# Step 3: Add to PATH (make permanent by adding to ~/.bashrc)
export PATH="$HOME/.local/bin:$PATH"
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc

# Step 4: Ensure login shells also load ~/.bashrc
# (bash login shells read ~/.bash_profile, NOT ~/.bashrc, by default)
echo '[[ -f ~/.bashrc ]] && . ~/.bashrc' >> ~/.bash_profile

# Step 5: Verify installation
rsi-cli-jtac --version

# Step 6: Grant write permission to your case directory (required for first run)
# The tool creates subfolders and extracts archives on first use.
chmod -R u+w /volume/CSdata/<your_username>/case/
```

Done! The tool is now ready to use on lnx02.

---

### Optional Setup (Python < 3.8 only)

If `python3 --version` shows < 3.8 on lnx02, install Python 3.13 via pyenv:

```bash
curl https://pyenv.run | bash
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
source ~/.bashrc
pyenv install 3.13 && pyenv global 3.13
pip install rsi-explorer-jtac --user
```

### Usage

Point the tool at the case directory — it will auto-detect the RSI file and var logs:

```bash
rsi-cli-jtac /volume/CSdata/<your_username>/case/<case-id>
```

### Interactive Commands

Inside the simulator:

```text
show version
show log ?
show log messages | match <keyword>
show chassis hardware detail no-forwarding
show log messages | last 50
show interfaces terse | match ge-0
quit
```

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

## Publish To PyPI (Maintainers)

1. Bump the version in `pyproject.toml`.
2. Build distributions:

```bash
python3 -m pip install --user -U build twine
python3 -m build
python3 -m twine check dist/*
```

3. Upload to TestPyPI first:

```bash
python3 -m twine upload --repository testpypi dist/*
```

4. Verify install from TestPyPI:

```bash
python3 -m pip install --user -U --index-url https://test.pypi.org/simple/ rsi-explorer-jtac
```

5. Upload to PyPI:

```bash
python3 -m twine upload dist/*
```

## Pipe Commands (`|`)
```text
show interfaces terse | match ge-0
show config | display set | save backup.conf
show interfaces | count
show route | except 0.0.0.0 | last 20
```

Available pipes: `no-more`, `save <file>`, `count`, `match <pattern>`, `except <pattern>`, `last <N>`, `find <pattern>`, `trim <N>`, `display set`

## Limitations
Simulation output is replayed from the RSI. If the RSI does not contain the command you request, you will see `Unknown command` message.

## CLI Options
```text
rsi-cli-jtac <case-directory>              # interactive mode
rsi-cli-jtac <case-directory> --no-pager  # disable paging
```

## Development
```bash
uv sync --dev
uv run pytest
uv run ruff check rsi/
uv run ruff format rsi/
```
