Metadata-Version: 2.4
Name: termcopy
Version: 0.2.1
Summary: A CLI tool for terminal clipboard operations
Home-page: https://github.com/scaryPonens/termco-py
Author: scaryPonens
Author-email: Reuben Peter-Paul <reuben@reubenpeterpaul.com>
License: MIT
Project-URL: Homepage, https://github.com/scaryPonens/termco-py
Project-URL: Repository, https://github.com/scaryPonens/termco-py
Project-URL: Issues, https://github.com/scaryPonens/termco-py/issues
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
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: Programming Language :: Python :: 3.12
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: pytest>=6.0.0; extra == "dev"
Requires-Dist: pytest-cov>=2.10.0; extra == "dev"
Requires-Dist: black>=21.0.0; extra == "dev"
Requires-Dist: flake8>=3.8.0; extra == "dev"
Requires-Dist: mypy>=0.800; extra == "dev"
Dynamic: author
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python

# termcopy

[![CI](https://github.com/scaryPonens/termco-py/actions/workflows/test.yml/badge.svg)](https://github.com/scaryPonens/termco-py/actions/workflows/test.yml)

A Python CLI tool for terminal clipboard operations, replicating the functionality of a bash script that sends OSC 52 escape sequences.

## Installation

### PyPI

```bash
pip install termcopy
```

### Debian/Ubuntu via apt

This repo includes Debian packaging metadata and a CI workflow that builds `.deb` artifacts.

To support:

```bash
apt install termcopy
```

you need a hosted APT repository (e.g., Cloudsmith, Packagecloud, or self-hosted Aptly/reprepro).

#### User install steps (after repo is published)

1. Install repository key (Cloudsmith example):

```bash
curl -fsSL https://dl.cloudsmith.io/public/thetranscend/relay/gpg.key \
  | sudo gpg --dearmor -o /usr/share/keyrings/termcopy-archive-keyring.gpg
```

2. Add apt source list (Debian bookworm):

```bash
echo "deb [signed-by=/usr/share/keyrings/termcopy-archive-keyring.gpg] https://dl.cloudsmith.io/public/thetranscend/relay/deb/debian bookworm main" \
  | sudo tee /etc/apt/sources.list.d/termcopy.list
```

3. Update and install:

```bash
sudo apt update
sudo apt install termcopy
```

> See `docs/APT_RELEASE.md` for maintainer-side publishing steps.

## Usage

The tool reads input from either a file or stdin, base64 encodes it, and outputs an OSC 52 escape sequence for clipboard operations.

### From a file:
```bash
termcopy filename.txt
```

### From stdin:
```bash
echo "Hello, World!" | termcopy
```

### From a pipe:
```bash
cat somefile.txt | termcopy
```

## How it works

The tool:
1. Detects whether input is coming from a terminal or pipe
2. Reads from a file argument if input is from terminal, otherwise reads from stdin
3. Base64 encodes the input data
4. Removes newlines from the base64 output
5. Wraps the result in an OSC 52 escape sequence for clipboard operations

## Development

To install in development mode:

```bash
pip install -e .
```

To install with development dependencies:

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

### Running tests

```bash
pytest tests/ -v
```

### Code formatting and linting

```bash
# Format code
black src/ tests/

# Check code style
flake8 src/ tests/

# Type checking
mypy src/
```

## CI/CD

This project uses GitHub Actions for continuous integration and deployment:

- **Test workflow** (`.github/workflows/test.yml`): Runs on every push and pull request
  - Tests against Python 3.8-3.12
  - Runs linting (black, flake8, mypy)
  - Uploads coverage reports

- **Publish workflow** (`.github/workflows/publish.yml`): Runs on version tags
  - Builds and publishes to PyPI
  - Also publishes to TestPyPI

- **Manual release workflow** (`.github/workflows/release.yml`): Can be triggered manually
  - Allows custom version releases
  - Optional publishing to PyPI/TestPyPI

- **Auto release workflow** (`.github/workflows/auto-release.yml`): Automated version incrementing
  - Automatically calculates next version (patch/minor/major)
  - Creates GitHub releases with tags
  - Updates version files and commits changes
  - Optional publishing to PyPI/TestPyPI

### Setting up PyPI publishing

1. Create API tokens on [PyPI](https://pypi.org/manage/account/token/) and [TestPyPI](https://test.pypi.org/manage/account/token/)
2. Add the tokens as GitHub secrets:
   - `PYPI_API_TOKEN`: Your PyPI API token
   - `TEST_PYPI_API_TOKEN`: Your TestPyPI API token

### Automated Releases

The auto-release workflow provides three release types:

- **Patch** (0.1.0 → 0.1.1): Bug fixes and minor improvements
- **Minor** (0.1.0 → 0.2.0): New features, backward compatible
- **Major** (0.1.0 → 1.0.0): Breaking changes

The workflow will:
1. Run all tests to ensure quality
2. Calculate the new version based on current version and release type
3. Update version in `pyproject.toml` and `src/termcopy/__init__.py`
4. Create a GitHub release with the new version tag
5. Commit and push the version changes
6. Optionally publish to PyPI/TestPyPI

## License

MIT License - see LICENSE file for details.
