Metadata-Version: 2.2
Name: ip2cidr
Version: 0.1.0
Summary: A tool to convert IP addresses to /24 CIDR notation
Home-page: https://github.com/greatbody/macpy-scripts
Author: greatbody
Author-email: sunruicode@gmail.com
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: argparse>=1.4.0
Provides-Extra: test
Requires-Dist: pytest>=7.0.0; extra == "test"
Requires-Dist: pytest-cov>=4.0.0; extra == "test"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# ip2cidr

A Python tool to convert IP addresses to /24 CIDR notation.

## Installation

```bash
pip install ip2cidr
```

## Usage

The tool can be used from the command line:

```bash
# Convert a single IP
ip2cidr -i "10.200.2.132"

# Convert multiple IPs (comma-separated)
ip2cidr -i "10.200.2.132,192.168.1.100,172.16.5.200"

# Use a different separator for output (default is comma)
ip2cidr -i "10.200.2.132,192.168.1.100" -s " "
```

### Arguments

- `-i, --ips`: Required. Comma-separated list of IP addresses to convert
- `-s, --separator`: Optional. Output separator (default: comma)

### Example Output

```bash
$ ip2cidr -i "10.200.2.132,192.168.1.100,172.16.5.200"
10.200.2.0/24,172.16.5.0/24,192.168.1.0/24

$ ip2cidr -i "10.200.2.132,192.168.1.100" -s " "
10.200.2.0/24 192.168.1.0/24
```

## Python Usage

You can also use the tool in your Python code:

```python
from ip_converter import ip_to_cidr

# Convert IPs to CIDR
ips = "10.200.2.132,192.168.1.100"
cidrs = ip_to_cidr(ips)
print(cidrs)  # ['10.200.2.0/24', '192.168.1.0/24']
```

## Development

### Running Tests

To run the tests, first install the development dependencies:

```bash
pip install -e ".[test]"
```

Then run the tests with pytest:

```bash
pytest
```

This will run all tests and generate a coverage report. The tests cover various scenarios including:
- Single IP conversion
- Multiple IP conversion
- Duplicate network handling
- Invalid IP handling
- Empty input
- Whitespace handling
- Partial IP addresses
- Special IP addresses (localhost, etc.)

## Features

- Converts IP addresses to their corresponding /24 CIDR networks
- Handles multiple IP addresses
- Removes duplicates and sorts the output
- Customizable output separator
- Error handling for invalid IP addresses
- Comprehensive test suite with 100% coverage

## Requirements

- Python 3.8 or higher
- argparse>=1.4.0

## License

MIT License 
