viewline
is a command-line tool that takes a filename or stream and displays the specified line in context. It is designed to make it easy to extract and view specific lines from text files or input streams.
- Display specific lines from a file or standard input.
- Handles both text and binary files gracefully.
- Provides context around the specified line for better understanding.
To install viewline
as a standalone application, use pipx:
pipx install git+https://github.com/dcloutman/viewline-command.git
This will make the viewline
command available globally.
If you are developing or contributing to viewline
, clone the repository and install it locally:
# Clone the repository
git clone https://github.com/dcloutman/viewline-command.git
cd viewline-command
# (Recommended) Create and activate a virtual environment
python3 -m venv .venv
source .venv/bin/activate
# Install in editable mode with development dependencies
pip install -e .[dev]
# Make your changes to the code
# Run tests to verify your changes
pytest
# Optionally, check code style and linting
ruff check .
The viewline
command can be used as follows:
viewline <filename> <line_number>
-
Display line 42 from a file:
viewline example.txt 42
-
Display line 42 from a file with line numbers:
viewline -n example.txt 42
-
Use
viewline
from a stream with line numbers:cat example.txt | viewline -n 42
-
Use
viewline
from a stream with line numbers but using pure ASCII (no terminal colors):cat example.txt | viewline --plain -n 42
Current version: 0.1.0
Contributions are welcome! Please fork the repository and submit a pull request with your changes.
This project is licensed under the MIT License. See the LICENSE file for details.