Copyright CLI Tool
A professional, multi-language copyright header management tool. Ensure compliance, maintain consistency, and manage project licensing with ease.
Features
Core Capabilities
- Multi-Language Support: Support for Python, JavaScript, TypeScript, Java, C/C++, Go, Rust, and Shell scripts.
- Intelligent Year Management: Automatic year range management with full 4-digit years (e.g., 2024-2026).
- Header Removal: Seamlessly strip copyright headers from files for open-source contributions.
- Git Integration: Automatic discovery of company name and email from Git configurations.
- SPDX Compliance: Full support for SPDX license identifiers and machine-readable formats.
- Configuration Layers: Flexible settings via .copyright.toml, pyproject.toml, or user-wide configuration.
- Validation Suite: Verify compliance in CI/CD pipelines without modifying source files.
- Preview Mode: Safely review pending changes using dry-run and verbose logging.
Installation
pip install copyright-cli-tool
Or install from source:
git clone https://github.com/rohan7654/copyright-cli-tool.git
cd copyright-cli-tool
pip install -e .
Quick Start
# Add copyright headers to current directory
copyright
# Specify company name
copyright --company "AcmeCorp"
# Use SPDX format with license
copyright --license MIT --format spdx
# Preview changes without modifying files
copyright --dry-run --verbose
# Validate headers in CI/CD
copyright --check
Usage
Basic Usage
# Process current directory with auto-detected company
copyright
# Specify path and company
copyright --path ./src --company "AcmeCorp"
# Add email to headers
copyright --company "AcmeCorp" --email "info@acmecorp.com"
Multi-Language Projects
# Process multiple file types
copyright --extensions .py .js .ts .java
# Process JavaScript/TypeScript project
copyright --extensions .js .ts .jsx .tsx
Exclusion Patterns
# Exclude specific patterns
copyright --exclude "tests/*" "docs/*" "*_test.py"
# Ignore .gitignore patterns
copyright --no-gitignore
SPDX Format
# Use SPDX format with license identifier
copyright --license MIT --format spdx
# Traditional format (default)
copyright --license MIT --format traditional
SPDX Format Output:
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2026 AcmeCorp <info@acmecorp.com>
Traditional Format Output:
# Copyright 2026 AcmeCorp. All rights reserved.
Validation Mode (CI/CD)
# Check if all files have valid headers
copyright --check
# Check with verbose output
copyright --check --verbose
# Exit code: 0 if valid, 1 if invalid
Dry-Run Mode
# Preview what would change
copyright --dry-run
# See detailed changes
copyright --dry-run --verbose
Remove Mode
The tool provides a dedicated mode for stripping copyright headers from source files. This is particularly useful for contributors preparing code for open-source repositories where project-wide headers are managed separately.
# Remove copyright headers from all Python files
copyright --remove
# Remove from specific file types
copyright --remove --extensions .py .js .ts
# Preview removal without modifying files
copyright --remove --dry-run --verbose
# Remove from specific directory
copyright --path ./src --remove
Configuration
Create a .copyright.toml file in your project root or ~/.copyright.toml for user-wide settings:
[tool.copyright]
company = "AcmeCorp"
email = "info@acmecorp.com"
license = "MIT"
format = "traditional"
file_extensions = [".py", ".js", ".ts", ".java"]
exclude = [
"tests/*",
"docs/*",
"*_test.py"
]
Or add to your pyproject.toml:
[tool.copyright]
company = "AcmeCorp"
email = "info@acmecorp.com"
license = "Apache-2.0"
format = "spdx"
Configuration Priority
When resolving properties like the company name or email, the tool follows a layered priority system:
- Command-line arguments: Flags provided directly to the CLI.
- Local Configuration:
.copyright.tomlin the current working directory. - Project Metadata:
[tool.copyright]section inpyproject.toml. - User Defaults:
~/.copyright.tomlin the user home directory. - Auto-discovery: Intelligence gathered from Git config (
user.name,user.email). - Interactive Prompt: If all previous layers fail to provide a company name, the tool will gracefully prompt for interactive input.
Advanced Usage
Pre-commit Hook
Add to your .pre-commit-config.yaml:
repos:
- repo: local
hooks:
- id: copyright-check
name: Check copyright headers
entry: copyright --check
language: system
pass_filenames: false
always_run: true
GitHub Actions
Create .github/workflows/copyright-check.yml:
name: Copyright Check
on: [pull_request, push]
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- run: pip install copyright-cli-tool
- run: copyright --check --company "Your Company"
GitLab CI
Add to your .gitlab-ci.yml:
copyright-check:
stage: test
image: python:3.10
script:
- pip install copyright-cli-tool
- copyright --check --company "Your Company"
Supported Languages
| Language | Extensions | Comment Style |
|---|---|---|
| Python | .py | # |
| JavaScript | .js, .jsx, .mjs | // |
| TypeScript | .ts, .tsx | // |
| Java | .java | // |
| C | .c, .h | // |
| C++ | .cpp, .hpp, .cc, .hh, .cxx | // |
| Go | .go | // |
| Rust | .rs | // |
| Shell | .sh, .bash | # |
Command-Line Options
usage: copyright [-h] [--version] [--path PATH] [--company COMPANY]
[--email EMAIL] [--license LICENSE]
[--format {traditional,spdx}]
[--extensions EXTENSIONS [EXTENSIONS ...]]
[--exclude EXCLUDE [EXCLUDE ...]] [--config CONFIG]
[--dry-run] [--check] [--remove] [--verbose] [--no-gitignore]
Options:
-h, --help Show this help message and exit
--version, -v Show program's version number and exit
--path PATH, -p PATH Directory path to scan (default: current directory)
--company COMPANY, -c COMPANY
Company name for copyright header
--email EMAIL, -e EMAIL
Email address for copyright header
--license LICENSE, -l LICENSE
SPDX license identifier (e.g., MIT, Apache-2.0)
--format {traditional,spdx}, -f {traditional,spdx}
Header format (default: traditional)
--extensions EXTENSIONS [EXTENSIONS ...]
File extensions to process (e.g., .py .js .ts)
--exclude EXCLUDE [EXCLUDE ...]
Glob patterns to exclude (e.g., 'tests/*' 'docs/*')
--config CONFIG Path to custom configuration file
--dry-run, -n Preview changes without modifying files
--check Validate headers without modification (exit 1 if issues)
--remove, -r Remove copyright headers from files
--verbose Show detailed output for each file
--no-gitignore Don't respect .gitignore patterns
Examples
Example 1: New Project Setup
# Initialize copyright headers for a Python project
copyright --company "MyCompany" --license MIT
# Or use configuration file
cat > .copyright.toml << EOF
[tool.copyright]
company = "MyCompany"
license = "MIT"
file_extensions = [".py"]
EOF
copyright
Example 2: Multi-Language Project
# Process Python, JavaScript, and TypeScript files
copyright --company "TechCorp" \
--extensions .py .js .ts \
--exclude "node_modules/*" "dist/*"
Example 3: SPDX Compliance
# Use SPDX format for open-source project
copyright --company "OpenSource Inc" \
--email "oss@example.com" \
--license Apache-2.0 \
--format spdx
Example 4: CI/CD Integration
# In CI pipeline
copyright --check --company "CI Corp"
# With custom config
copyright --check --config .copyright.toml
Year Range Logic
The tool intelligently manages copyright year ranges with full 4-digit years:
| Existing Header | Current Year | Result |
|---|---|---|
| Copyright 2025 AcmeCorp. All rights... | 2026 | Copyright 2025-2026 AcmeCorp. All rights... |
| Copyright 2025-2026 AcmeCorp. All rights.. | 2026 | (unchanged) |
| (no header) | 2026 | Copyright 2026 AcmeCorp. All rights... |
| Copyright 2024-2025 AcmeCorp. All rights.. | 2026 | Copyright 2024-2026 AcmeCorp. All rights... |
Troubleshooting
Issue: Git auto-detection not working
Solution: Ensure you're in a git repository and have configured git:
git config user.name "Your Name"
git config user.email "your@email.com"
Issue: Files not being processed
Solution: Check if files are excluded by .gitignore or default exclusions. Use --no-gitignore or --verbose to debug.
Issue: Unsupported file type
Solution: The file extension may not be supported yet. Check the supported languages table above.
Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests if applicable
- Run tests:
pytest - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Development Setup
git clone https://github.com/rohan7654/copyright-cli-tool.git
cd copyright-cli-tool
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -e ".[dev]"
License
This project is licensed under the MIT License - see the LICENSE file for details.
You are free to:
- Use the software commercially
- Modify and distribute the code
- Include it in private or open-source projects
Under the following conditions:
- The original copyright and license notice must be included
- The software is provided "as is", without warranty of any kind
Support
If you encounter any issues or have questions:
- Open a GitHub Issue
- Include clear steps to reproduce the issue
- Provide environment details (OS, Python version, etc.)
Changelog
See CHANGELOG.md for a detailed history of changes.
Acknowledgments
- Built with Rich for beautiful terminal output
- Inspired by tools like addlicense, licenseheaders, and HashiCorp Copywrite
- Thanks to all contributors and users
Metadata
Release files for copyright-cli-tool 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| copyright_cli_tool-0.1.0.tar.gz | 17.7 kB | Without provenance | Details for copyright_cli_tool-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| copyright_cli_tool-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for copyright_cli_tool-0.1.0-py3-none-any.whl |
Total release size: 32.7 kB
Release files / copyright_cli_tool-0.1.0.tar.gz
| Download URL | copyright_cli_tool-0.1.0.tar.gz |
|---|---|
| Size | 17.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c9a1d27499ec02288d82b45f2f8cfdb1750fda8095b723c64383bf14bcf5a072
|
|
BLAKE2b-256 checksum How to use checksums |
c2b9b1f5f88825bd624fb8b57a39672e446d77da652d888e8db6feac3b134bb0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.0
|
Release files / copyright_cli_tool-0.1.0-py3-none-any.whl
| Download URL | copyright_cli_tool-0.1.0-py3-none-any.whl |
|---|---|
| Size | 15.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e3c24670de092b7561d24dae1c239e801ce4f0263c91f36aa59d74cb5c5e3ab6
|
|
BLAKE2b-256 checksum How to use checksums |
faf2e9f015b2abde1d778bb29fd4901291c5c62e42995db7ee2157756755a21a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.0
|
Security for copyright-cli-tool 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.