A command-line tool for counting unique characters in strings or files
Project description
🖥️ Task 4 CLI Character Counter
A command-line interface application developed as part of the Foxminded course. This code provides a convenient command-line tool for counting unique characters in strings or files, with error handling and performance optimization through memoization.
📋 Requirements
🚀 Installation
git clone https://git.foxminded.ua/foxstudent106775/task_4_cli.git
💻 Usage
How to Run
-
Open your Terminal/Command Prompt: Navigate to the directory containing unique_chars.py using the
cdcommand. -
Run the Application:
Using a String Input:
python unique_chars.py --string "your string here"
Examples:
python unique_chars.py --string "hello world" python unique_chars.py --string "AaBbCc123"
Using a File Input:
python unique_chars.py --file "your_file.txt"
Examples:
# Local file python unique_chars.py --file "my_text.txt" # Absolute path (Unix/Linux) python unique_chars.py --file "/path/to/your/file/data.txt" # Absolute path (Windows) python unique_chars.py --file "C:\folder\file.txt"
🎯 Available Options
| Option | Description |
|---|---|
--string "string" |
Specifies the input string to be analyzed (must be in double quotes) |
--file "file_path" |
Specifies the path to the text file to be analyzed (must be in double quotes) |
📝 Expected Outputs
✅ Successful Execution
Number of unique characters: [number]
Where
[number]is the count of characters that appear only once in the input.
❌ Error Outputs
| Error Type | Message | Description |
|---|---|---|
| ValueError | No input provided. Use --string or --file |
No input option provided |
| FileNotFoundError | File not found: [file_path] |
Specified file doesn't exist |
| IOError | Error reading file: [error_message] |
File reading problems |
| Exception | Error: [error_message] |
Other unexpected errors |
📊 Example Scenarios
-
Counting unique characters in a string:
$ python unique_chars.py --string "aabbcde" Number of unique characters: 3 # (c, d, and e appear once)
-
Counting unique characters in a file:
$ python unique_chars.py --file "data.txt" # data.txt contains "122345" Number of unique characters: 3 # (1, 3, and 5 appear once)
📁 Project Structure
task_4_cli/
├── CollectionFramework/
│ ├── collection.py
│ └── __init__.py
├── tests/
│ ├── __init__.py
│ └── test_collect.py
🧪 Testing
Run tests using pytest with coverage:
pytest --cov=CollectionFramework tests/
👨💻 Author
Volodymyr Savchenko
📄 License
[]
Made in Python
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file unique_chars_counter_vs-0.1.0.tar.gz.
File metadata
- Download URL: unique_chars_counter_vs-0.1.0.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
150cd0113cd3ba0d6a89f5d083120eec768d89ceb08c00d1a6613693a1e0ecf6
|
|
| MD5 |
629f8d1e11df4b0e2f7fc4a24d8b098c
|
|
| BLAKE2b-256 |
08e987aafd5f8e5b5f795e9cb827cff05829b620561eb5795d84a53742ca9c15
|
File details
Details for the file unique_chars_counter_vs-0.1.0-py3-none-any.whl.
File metadata
- Download URL: unique_chars_counter_vs-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c7aa5f0f0429ff644a8a927a50afdc721ae3cc82547ee899a26585ba8609f47
|
|
| MD5 |
b0c13971133c1bc9a8b3aa56aa3aef2d
|
|
| BLAKE2b-256 |
1e7bd92eee863df58c8348003aa9371f4d95f0ac0ac12f7575e3a347e6876ebe
|