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

🚀 Usage

Suppose your main script is named main.py.

Analyze a single string:

python main.py --string "Example"

Analyze lines from a file:

python main.py --file path/to/file.txt

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

Provide both string and file:

python main.py --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.0.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.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cli_string-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 2857f17c4e4cb7cf7d798a8570d76d4c1eef68c24aa0e457737f059440b4ec38
MD5 e1befc44ebf0b7b55302466dc2e1be8a
BLAKE2b-256 5b20829480314b30d5478fea5bfb65cd2a19f35b9641e175bd9e732c8ab0aa29

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cli_string-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 29f08208da004b45b4f3871e53968a25e8338ffaadba139002dcc1270cb7c366
MD5 cea9d8b78fc9a0ba39ec63f04cd31e0b
BLAKE2b-256 5646d568c1668378ac425baf9caa13b1e8196411d7f23d9be85044cf5be512e2

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