Skip to main content

This CLI tool analyzes a string or a file containing strings and outputs **only the characters that appear exactly once** in each line (case-insensitive). Additionally, it measures the execution time of the function call.

Project description

Unique Characters in a String

This CLI tool analyzes a string or a file containing strings and outputs only the characters that appear exactly once in each line (case-insensitive). Additionally, it measures the execution time of the function call.


🔍 Features

  • ✅ Detects unique characters only (characters that appear exactly once).
  • 🔠 Case-insensitive comparison (e.g., 'A' and 'a' are treated as the same).
  • ♻️ Result caching with functools.lru_cache for optimized repeated calls.
  • Execution time logging using the custom perf_counter_deco decorator.

📦 Installation

  1. Make sure you're using Python 3.12 or later.
  2. Install the package locally or from a distribution (if published):
pip install cli_string

or

poetry add cli_string

🚀 Usage

Analyze a single string:

cli_string --string "Example"

Analyze lines from a file:

cli_string --file path/to/file.txt

⚠️ If both --string and --file are provided, the file input takes precedence.

Provide both string and file:

cli_string --file path/to/file.txt --string "Example"

If no arguments are provided:

Please provide a string or a file with lines to process.

📤 Example Output

String: 'Hello, World' => Unique characters: he, wrd

🧠 Function Breakdown

count_chars_in_string(s: str) -> str • Validates input type and non-emptiness. • Uses collections.Counter to identify characters that appear only once. • Returns the resulting characters in lowercase. • Output is cached using @lru_cache. • Execution time is measured with the @perf_counter_deco.

main() • Parses command-line arguments: • --string: input string to analyze. • --file: path to a file containing strings. • Prioritizes file input if both are passed. • Prints formatted results for each line. • Handles missing arguments gracefully.

📁 Project Structure

cli_string/ ├── init.py ├── main.py ├── utils.py pyproject.toml README.md

👨‍💻 Author

Daniel Kravchenko 📧 daniel.kravchenko@protonmail.com

📄 License

Distributed under the MIT License.


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

cli_string-0.1.2.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

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

cli_string-0.1.2-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file cli_string-0.1.2.tar.gz.

File metadata

  • Download URL: cli_string-0.1.2.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for cli_string-0.1.2.tar.gz
Algorithm Hash digest
SHA256 eb02ec74d28590d2c28e1faf4853d4857f5ed6b757554855ac1ccf9d01f4127a
MD5 b4d9d665a37947f411384a698273f04e
BLAKE2b-256 a2c18d4cfbda2f5168bb948ecda4b0b237c05b7ac1923574a303b07885b57304

See more details on using hashes here.

File details

Details for the file cli_string-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: cli_string-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for cli_string-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b762d6b4ea6616573dc1db7cabc438324135360799d2f3b5adfabe85d068d16b
MD5 fc506dec8d572803e6d558a6c83177a9
BLAKE2b-256 4dc848b30156e76d5a553771544ba4f812c59554df6391e4d0e73695f2807ea5

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