Giter VIP home page Giter VIP logo

licensesnip's Introduction

๐Ÿ”‘ licensesnip

Tool to automatically add license headers to your source code. Customizable for any language.

Licensesnip is written is Rust and is fast and reliable โšก.

๐Ÿ“ฆ Install

With Cargo

cargo install licensesnip

๐Ÿ“œ Usage

In your project's root directory, add a file named .licensesnip and write your license header there. Licensesnip will automatically replace %FILENAME% with the file name and %YEAR% with the year.

To add license headers to all your source code:

licensesnip

Licensesnip ignores files in your .gitignore file by default. You can also add a file named .licensesnipignore and specify patterns the same way as in a .gitignore file.

To remove license headers from all source code:

licensesnip remove

To check if license headers are present in all of your source files:

licensesnip check

You can also specify a specific path or file to modify:

# Add licenses to src/main.rs
licensesnip src/main.rs
# Remove licenses from src folder
licensesnip remove src/

Pre-commit hook

You can use licensesnip with pre-commit. Add it to your local .pre-commit-config.yaml as follows:

- repo: https://github.com/notken12/licensesnip
  rev: 19b1186 # choose your preferred tag or commit hash
  hooks:
    - id: licensesnip
      args: ["check"] # optionally modify the arguments for licensesnip (default arguments shown here)

โš™๏ธ Configuration

Find your global Licensesnip config file:

licensesnip config

Create/find the local config file for the current directory:

licensesnip config -d

Example configuration:

{
  "use_gitignore": true,
  "file_types": {
    "js,mjs,ts,cjs,jsx,tsx": {
      "before_line": "// "
    },
    "vue,html": {
      "before_block": "<!--",
      "before_line": "  ",
      "after_block": "-->"
    },
    "rs": {
      "before_line": "// "
    },
    "c": {
      "enable": false
    }
  }
}

To configure a language just specify how the comments for that language work. Supported properties are before_line, after_line, before_block, and after_block. To disable adding licenses to a filetype, set enable to false.

โค๏ธ Contribution

I haven't added builtin support for many languages yet. Please help out and add your favorite languages to src/base-config.jsonc and submit a pull request. Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.