Metadata-Version: 2.5
Name: count-letters
Version: 0.1.0
Summary: CLI application for counting characters that occur only once
Author-email: Alex Kravets <sashakravets73@gmail.com>
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# Count Letters

`count-letters` is a simple Python package for counting characters that appear only once in a text.

The package can be used from the command line or directly in Python code.

## Features

- Count unique characters in a string
- Read text from a UTF-8 file
- Use the package from the command line
- Use the package in Python code
- Supports Python 3.10 and newer

## Requirements

- Python 3.10 or newer

## Installation

Install the package from PyPI:

```bash
pip install count-letters
```

## Command Line Usage

After installation, the `count-letters` command is available.

### Count characters in a string

```bash
count-letters --string "hello"
```

Short version:

```bash
count-letters -s "hello"
```

Output:

```text
3
```

The characters `h`, `e`, and `o` appear only once, so the result is `3`.

### Count characters from a file

Create a UTF-8 text file, for example `text.txt`:

```text
hello
```

Run:

```bash
count-letters --file text.txt
```

or:

```bash
count-letters -f text.txt
```

Output:

```text
3
```

### Using both arguments

If `--file` and `--string` are used together, `--file` has priority.

```bash
count-letters --string "error" --file text.txt
```

In this case, the program reads and processes the content of `text.txt`.

### File errors

If the specified file does not exist, the program shows an error message:

```bash
count-letters --file missing.txt
```

```text
error: Файл не знайдено
```

## Using as a Python Package

You can also use the package directly in Python code:

```python
from count_letters.collection import count_unique_letters

result = count_unique_letters("hello")
print(result)
```

Output:

```text
3
```

To read text from a file:

```python
from count_letters.collection import open_and_read_file

text = open_and_read_file("text.txt")
print(text)
```

## Help

To see all available command-line options:

```bash
count-letters --help
```

## Development

Install the project and development dependencies:

```bash
uv sync
```

Run tests:

```bash
uv run pytest
```

Run code checks:

```bash
uv run ruff check .
uv run ruff format --check .
uv run mypy count_letters tests
```

## Build

Build the package with:

```bash
uv build
```

The built package files will be created in the `dist` directory.