Skip to main content

A custom tail command line tool using Python and Click.

Project description

📜 Для проєкту custom-tail (README.md)

# Custom Tail CLI (`ctail`)

[![PyPI version](https://badge.fury.io/py/custom-tail-cli.svg)](https://badge.fury.io/py/custom-tail-cli)
[![Build Status](https://github.com/bohdanfariyon/custom-tail/actions/workflows/publish.yml/badge.svg)](https://github.com/bohdanfariyon/custom-tail/actions)

A simple command-line utility written in Python to display the last few lines of a file, mimicking the basic functionality of the GNU `tail` command. This tool is built using the `click` library.

---

## 🚀 Features

* **Show Last Lines**: Display the last N lines of a file (10 by default).
* **Follow Mode**: Watch a file for changes and output new lines as they are added (`-f` option).
* **Custom Line Count**: Specify the exact number of lines to display.
* **Dockerized**: Comes with a `Dockerfile` for easy containerization.

---

## 📦 Installation

You can install the package directly from PyPI:

```bash
pip install custom-tail-cli

🛠️ Usage

The main command is ctail. You must provide a file path.

Basic Usage

Show the last 10 lines of logfile.log.

ctail logfile.log

Command Options

  • -n, --lines <number>: Specify the number of lines to show.

    # Show the last 5 lines
    ctail -n 5 logfile.log
    
  • -f, --follow: "Follow" mode. The command will wait and display new lines as they are written to the file. This is useful for monitoring log files in real-time.

    ctail -f /var/log/syslog
    

    (Press Ctrl+C to exit follow mode.)


🐳 Docker Usage

You can also build and run this tool as a Docker container.

  1. Build the image:

    docker build -t ctail-app .
    
  2. Run the container:

    To see the help message:

    docker run --rm ctail-app --help
    

    To view the tail of a file from your current directory, you need to mount it as a volume:

    # This command mounts the current directory to /data inside the container
    # and tells ctail to read the file /data/logfile.log
    docker run --rm -v "$(pwd)":/data ctail-app /data/logfile.log
    

    To use follow mode on a local file:

    docker run --rm -v "$(pwd)":/data ctail-app -f /data/logfile.log
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

custom_tail_cli-0.1.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

custom_tail_cli-0.1.0-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file custom_tail_cli-0.1.0.tar.gz.

File metadata

  • Download URL: custom_tail_cli-0.1.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for custom_tail_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 eca02bdad08535c74178ba7395b5164a8fb267205b46347fd4bbc2c134c058c4
MD5 4f10d5180ac027ff21866e0b2ff7fe7a
BLAKE2b-256 f93642dd46fe26871f198cbbfb91707584ae3c390cf32ab54252d0aed5cae31f

See more details on using hashes here.

File details

Details for the file custom_tail_cli-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for custom_tail_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 48ff027a925411f573fb10dbe78fc061494b77eab572ceb0d208d90524e08258
MD5 6084754a687b21e3228c35842558ba03
BLAKE2b-256 ddcedfe5c52279eb952ff19b6f9d5edbcb0e7636b2360ee4146ee836d006adf5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page