Skip to main content

Tool to automatically add, update, or delete multi-format copyright headers

Project description

pre-commit.ci status


cr-manager -- the Copyright Header Manager

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


Features

  • 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.

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.
--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.

Add New Copyright Headers

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

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

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

Update Existing Copyright Headers

[!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

Delete Existing Copyright Headers

[!TIP] --filetype <TYPE> can be used to force a specific filetype for the update 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

# *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 .py, .sh, .dockerfile
$ cr-manager --filetype python

result

#===============================================================================
# Copyright © 2025 marslo                                                      #
# Licensed under the MIT License, Version 2.0                                  #
#===============================================================================

Python


FILETYPE SUFFIXES
jenkinsfile, groovy, gradle, java .groovy, .java
$ cr-manager --filetype groovy

result

/**
 *******************************************************************************
 * Copyright © 2025 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
$ cr-manager --filetype cpp

result

/**
 * Copyright © 2025 marslo
 * Licensed under the MIT License, Version 2.0
 */

c/cpp


Install

Binary

  • pipx installation
    $ 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)"

pre-commit hook

---
repos:
  - repo: https://github.com/marslo/cr-manager
    rev: v3.0.3
    hooks:
      - id: cr-manager
        args: ["--update", "--copyright", "/path/to/COPYRIGHT"]
        files: ^(jenkinsfile/|.*\.(groovy|py|sh)$)

only check the copyright headers without modifying files after commit

---
repos:
  - repo: https://github.com/marslo/cr-manager
    rev: v3.0.3
    hooks:
      - id: cr-manager
        args: ["--check"]
        stages: [post-commit]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cr_manager-3.0.4.1.tar.gz (17.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cr_manager-3.0.4.1-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

Details for the file cr_manager-3.0.4.1.tar.gz.

File metadata

  • Download URL: cr_manager-3.0.4.1.tar.gz
  • Upload date:
  • Size: 17.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.14.0 Darwin/25.1.0

File hashes

Hashes for cr_manager-3.0.4.1.tar.gz
Algorithm Hash digest
SHA256 3d2596e2ca46fd379e8753d29e0d11bc3912c6be7bd9a38896c234710cbc2624
MD5 778e95f610ce59978ceb63445db78e54
BLAKE2b-256 4ba12dadd470205f1be1514cd1ba820f58939a26811a189640b258822d13251c

See more details on using hashes here.

File details

Details for the file cr_manager-3.0.4.1-py3-none-any.whl.

File metadata

  • Download URL: cr_manager-3.0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 18.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.14.0 Darwin/25.1.0

File hashes

Hashes for cr_manager-3.0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5554c9082643b0979ea128bc2af78a3d6e098eecaef530553e8ceabc4e5c122b
MD5 56a3649a39da6f10c0006f8d53ad832b
BLAKE2b-256 87ed4d726c2065646ac2086d352d39c9cf5827fa18343e5b2f281cffc904a60c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page