Skip to main content

pre-commit.ci status publish to PyPI semantic-release

Linux macOS Windows License


cr-manager -- the Copyright Header Manager

A tool to automatically add, update, or delete multi-format copyright headers in source files.


GitHub Release GitHub Downloads Python PyPI version Install with pipx



Features and Format

  • Add: Insert copyright headers for multiple file types.
  • Update: Force update or insert headers if missing.
  • Check: Verify the presence and correctness of headers.
  • Delete: Remove detected copyright headers from files.
  • Supports recursive directory traversal and filetype auto-detection or override.
  • Supports combined author-info and copyright headers.
FORMAT FILETYPE SUFFIXES
# ========================== #
# Copyright © 2026 Marslo    #
# Licensed under MIT         #
# ========================== #
python
shell
bash
sh
dockerfile
containerfile
.py
.sh
.dockerfile
.containerfile
Dockerfile*
/**
 *****************************
 * Copyright © 2026 Marslo   *
 * Licensed under MIT        *
 *****************************
**/
jenkinsfile
groovy
gradle
java
.groovy
.java
/**
 * Copyright © 2026 Marslo
 * Licensed under MIT
 */
c
cpp
c++
cxx
h
hpp
hxx
.c
.cpp
.cxx
.hpp
.hxx
// ==========================
//  Copyright © 2026 Marslo
//  Licensed under MIT
// ==========================
rust
rs
.rs
/*!
 *****************************
 * Copyright © 2026 Marslo   *
 * Licensed under MIT        *
 *****************************
 */
css
javascript
js
.css
.js
.mjs
.cjs
<!--
 ===========================
  Copyright © 2026 Marslo
  Licensed under MIT
 ===========================
-->
html
xhtml
.html
.htm
.xhtml

How to Contribute


Action Modes

without any action mode specified, the default action is to add copyright headers.

OPTION DESCRIPTION
Add mode: Automatically adds copyright headers to files (default).
--add Add mode: Automatically adds copyright headers to files (default).
--check Check mode: Verifies file copyright status (match, mismatch, or not found).
--delete Delete mode: Removes detected copyright headers from files.
--update Update mode: Forces replacement of copyright or adds it if missing.
# single file
cr-manager /path/to/file
# or
cr-manager --add /path/to/file

# files recursively in directories
cr-manager --recursive /path/to/directory
# or
cr-manager --add --recursive /path/to/directory

# add to non-supported suffixes with supplied filetype
# -- e.g. add to .txt files as python files --
cr-manager --filetype python /path/to/file.txt
# or
cr-manager --add --filetype python /path/to/file.txt

TIP: --filetype <TYPE> can be used to force a specific filetype for the update action, overriding auto-detection.

# single file
cr-manager --update /path/to/file

# files recursively in directories
cr-manager --update --recursive /path/to/directory

TIP: --filetype <TYPE> can be used to force a specific filetype for the delete action, overriding auto-detection.

# single file
cr-manager --delete /path/to/file

# files recursively in directories
cr-manger --delete --recursive /path/to/directory

Debug Mode

# *add* without modifying files
cr-manager --debug /path/to/file
# or
cr-manager --add --debug /path/to/file

# *update* without modifying files
cr-manager --update --debug /path/to/file

# *delete* without modifying files
cr-manager --delete --debug /path/to/file

Supported File Types and Formats

FILETYPE SUFFIXES
python, shell, bash, sh, dockerfile, containerfile .py, .sh, .dockerfile, .containerfile, Dockerfile* / *.Dockerfile / Containerfile* ( case-insensitive )
# ============================================================================ #
# Copyright © 2026 marslo                                                      #
# Licensed under the MIT License, Version 2.0                                  #
# ============================================================================ #

Python


FILETYPE SUFFIXES
jenkinsfile, groovy, gradle, java .groovy, .java
/**
 *******************************************************************************
 * Copyright © 2026 marslo                                                     *
 * Licensed under the MIT License, Version 2.0                                 *
 *******************************************************************************
**/

java-groovy


FILETYPE SUFFIXES
c, cpp, c++, cxx, h, hpp, hxx .c, .cpp, .cxx, .h, .hpp, .hxx
/**
 * Copyright © 2026 marslo
 * Licensed under the MIT License, Version 2.0
 */

c/cpp


FILETYPE SUFFIXES
rust, rs .rs
// =============================================================================
//  Copyright © 2026 marslo
//  Licensed under the MIT License, Version 2.0
// =============================================================================

FILETYPE SUFFIXES
css, javascript, js .css, .js, .mjs, .cjs
/*!
 *******************************************************************************
 * Copyright © 2026 marslo                                                     *
 * Licensed under the MIT License, Version 2.0                                 *
 *******************************************************************************
 */

FILETYPE SUFFIXES
html, xhtml .html, .htm, .xhtml
<!DOCTYPE html>
<!--
 ===============================================================================
  Copyright © 2026 marslo
  Licensed under the MIT License, Version 2.0
 ===============================================================================
-->
  • the header is inserted below a leading <?xml ...?> / <!DOCTYPE ...> line

Install

binary

  • pipx installation ( how to install pipx )
    python3 -m pip install pipx
    python3 -m pipx ensurepath
    
  • enable the ansicolor in Windows terminal for better output experience.
    reg add HKCU\Console /v VirtualTerminalLevel /t REG_DWORD /d 1
    
# via pipx
pipx install --force "git+https://github.com/marslo/cr-manager"
# via pip
python3 -m pip install cr-manager

# with binary
VERSION="$(curl -fsSL https://api.github.com/repos/marslo/cr-manager/releases/latest | jq -r .tag_name)"
# -- linux --
curl -fsSL -o cr-manager https://github.com/marslo/cr-manager/releases/download/${VERSION}/cr-manager-linux
# macos
curl -fsSL -o cr-manager https://github.com/marslo/cr-manager/releases/download/${VERSION}/cr-manager-macos
# Windows - running in cmd
> powershell -NoProfile -Command "$v=(Invoke-WebRequest -Uri 'https://api.github.com/repos/marslo/cr-manager/releases/latest' -UseBasicParsing | ConvertFrom-Json).tag_name; Invoke-WebRequest -Uri ('https://github.com/marslo/cr-manager/releases/download/'+$v+'/cr-manager.exe') -OutFile 'cr-manager.exe'; Write-Host ('Downloaded '+$v)"

bash completion

automatically detect the OS and install bash completion to the appropriate directory:

  • macos: $(brew --prefix)/etc/bash_completion.d → $XDG_DATA_HOME/.local/share → ~/.bash_completion.d
  • linux: $XDG_DATA_HOME/.local/share → ~/.bash_completion.d → /usr/share/bash-completion/completions → /etc/bash_completion.d
# macos
cr-manager --install-completion
# or install manually
cr-manager --completion | tee "$(brew --prefix)/etc/bash_completion.d/cr-manager"
# linux user folder
cr-manager --install-completion
# or install manually
cr-manager --completion | tee ~/.bash_completion.d/cr-manager

# linux system folder (requires sudo)
sudo cr-manager --install-completion
# or install manually
cr-manager --completion | sudo tee /etc/bash_completion.d/cr-manager
# uninstall
test -f ~/.bash_completion.d/cr-manager   && rm -rf ~/.bash_completion.d/cr-manager
test -f /etc/bash_completion.d/cr-manager && sudo rm -rf /etc/bash_completion.d/cr-manager
[[ 'Darwin' = "$(uname -s)" ]] && test -f "$(brew --prefix)/etc/bash_completion.d/cr-manager" && rm -rf "$(brew --prefix)/etc/bash_completion.d/cr-manager"

pre-commit hook

cr-manager pre-commit hook

# if `COPYRIGHT` file can be found in the root directory of this repository
---
repos:
  - repo: https://github.com/marslo/cr-manager
    rev: v4.1.0
    hooks:
      - id: cr-manager
        args: ["--update"]
# install with git repo
---
repos:
  - repo: https://github.com/marslo/cr-manager
    rev: v4.1.0
    hooks:
      - id: cr-manager
        args: ["--update", "--copyright", "path/to/COPYRIGHT"]
        files: ^(jenkinsfile/|.*\.(groovy|py|sh)$)
# install with local repo + pypi package
---
repos:
  - repo: local
    hooks:
      - id: cr-manager
        name: cr-manager
        language: python
        additional_dependencies: ["cr-manager==4.1.0"]
        entry: cr-manager
        args: ["--update", "--copyright", "COPYRIGHT"]
        files: ^(jenkinsfile/|.*\.(groovy|py|sh)$)
        require_serial: true

IMPORTANT: require_serial: true is required for the local repo recipe so pre-commit passes all matched files to a single cr-manager invocation. Without it, pre-commit splits the files across multiple concurrent processes and the progress counter restarts per batch (e.g. 1/4 … 4/4 twice instead of 1/8 … 8/8). The repo:-based recipes inherit this automatically from the hook definition.

# only check the copyright headers without modifying files after commit
---
repos:
  - repo: https://github.com/marslo/cr-manager
    rev: v4.1.0
    hooks:
      - id: cr-manager
        args: ["--check"]
        stages: [post-commit]
# Dockerfile / Containerfile ( case-insensitive name part: Dockerfile, Dockerfile.dev, app.Dockerfile, build.dockerfile )
# other names: override `files`; keep `--filetype dockerfile` when overriding `args`
---
repos:
  - repo: https://github.com/marslo/cr-manager
    rev: v4.1.0
    hooks:
      - id: cr-manager-dockerfile
        args: ["--update", "--filetype", "dockerfile", "--copyright", "COPYRIGHT"]
        # files: ^docker/images/

Help Message

cr-manager --help
USAGE:
  cr-manager [--add | --check | --delete | --update] [--copyright FILE] [--filetype TYPE] [--recursive]
             [--debug] [--verbose] [--completion] [--install-completion] [--help] [--version]
             FILES ...

A tool to automatically add, update, or delete multi-format copyright headers.

POSITIONAL ARGUMENTS:
  FILES ...                 List of target files or directories to process.

ACTION MODES:
  -a, --add                 Add mode: Adds copyright header to files that are missing it (default).
  -c, --check               Check mode: Verifies file copyright status (match, mismatch, or not found).
  -d, --delete              Delete mode: Removes detected copyright headers from files.
  -u, --update              Update mode: Forces replacement of copyright or adds it if missing.

OPTIONS:
  --copyright FILE          Specify the copyright template file path (default: COPYRIGHT).
  -t, --filetype TYPE       Force override a filetype instead of auto-detection.
                            If provided, displays a formatted preview for that type. Supported: bash, c,
                            c++, containerfile, cpp, css, cxx, dockerfile, gradle, groovy, h, hpp, html,
                            hxx, java, javascript, jenkinsfile, js, python, rs, rust, sh, shell, xhtml
  -r, --recursive           If FILES includes directories, process their contents recursively.
  --debug                   Debug mode: Preview the result of an action without modifying files.
  --verbose                 Show a detailed processing summary.
  --completion              Print the bash completion script to stdout.
  --install-completion      Install bash completion to the OS-appropriate directory (auto-detected, no
                            root needed by default).
  -h, --help                Show this help message and exit.
  -v, --version             Show program's version number and exit.

Metadata

Release files for cr-manager 4.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cr-manager 4.1.0
File Size Uploaded Provenance Actions
cr_manager-4.1.0.tar.gz 27.5 kB Without provenance Details for cr_manager-4.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cr-manager 4.1.0
File Interpreter ABI Platform Actions
cr_manager-4.1.0-py3-none-any.whl Python 3 none any Details for cr_manager-4.1.0-py3-none-any.whl

Total release size: 54.8 kB

Release files / cr_manager-4.1.0.tar.gz

Download URL cr_manager-4.1.0.tar.gz
Size 27.5 kB
Tags Source
SHA-256 checksum
How to use checksums
959b31b6ca359946d79e57900b65d29d06a0b71e083c23ded1ef4fc0e8994d25
BLAKE2b-256 checksum
How to use checksums
f7fe1454093e3818d206c3551f0349ea43db7bd019d9d1fdf4f77230f135da90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.5.2 CPython/3.14.10 Linux/7.0.0-1020-azure

Release files / cr_manager-4.1.0-py3-none-any.whl

Download URL cr_manager-4.1.0-py3-none-any.whl
Size 27.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
99507d579b62acb1677de07dacfbfc09542a75861e54403155ab0b5a6dba5679
BLAKE2b-256 checksum
How to use checksums
6aae3fa9ad7c04c75873741ca2d1295db577e687fb1ecb4e4a1a11fadc3270f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.5.2 CPython/3.14.10 Linux/7.0.0-1020-azure

Security for cr-manager 4.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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page