smallhadroncollider / Cmt

Licence: other
Write consistent git commit messages based on a custom template

Programming Languages

haskell
3896 projects

Projects that are alternatives of or similar to Cmt

Textwrap
An efficient and powerful Rust library for word wrapping text.
Stars: ✭ 164 (-8.38%)
Mutual labels:  formatting
Slacker Cli
Messages to slack from command line
Stars: ✭ 172 (-3.91%)
Mutual labels:  command-line
Magicli
Automagically generates command-line interfaces (CLI) for any module. Expected options and help sections are created automatically based on parameters names, with support to async.
Stars: ✭ 178 (-0.56%)
Mutual labels:  command-line
Sqlcheck
Automatically identify anti-patterns in SQL queries
Stars: ✭ 2,062 (+1051.96%)
Mutual labels:  command-line
Exa
A modern replacement for ‘ls’.
Stars: ✭ 15,471 (+8543.02%)
Mutual labels:  command-line
Tably
Python command-line script for converting .csv data to LaTeX tables
Stars: ✭ 173 (-3.35%)
Mutual labels:  command-line
Terminal Discord
NOT MAINTAINED Simple terminal client for discord with a minimal look and UI
Stars: ✭ 162 (-9.5%)
Mutual labels:  command-line
Pqiv
Powerful image viewer with minimal UI
Stars: ✭ 177 (-1.12%)
Mutual labels:  command-line
Ddgr
🦆 DuckDuckGo from the terminal
Stars: ✭ 2,243 (+1153.07%)
Mutual labels:  command-line
Yarnhook
Run `yarn install`, `npm install` or `pnpm install` on git hooks automatically
Stars: ✭ 177 (-1.12%)
Mutual labels:  command-line
Asciigenome
Text Only Genome Viewer!
Stars: ✭ 168 (-6.15%)
Mutual labels:  command-line
Qoa
Minimal interactive command-line prompts
Stars: ✭ 2,007 (+1021.23%)
Mutual labels:  command-line
Neph
A modern command line job processor, similar with make command
Stars: ✭ 174 (-2.79%)
Mutual labels:  command-line
Command Line Api
Command line parsing, invocation, and rendering of terminal output.
Stars: ✭ 2,418 (+1250.84%)
Mutual labels:  command-line
Sd
Intuitive find & replace CLI (sed alternative)
Stars: ✭ 2,755 (+1439.11%)
Mutual labels:  command-line
Receivemidi
Multi-platform command-line tool to monitor and receive MIDI messages
Stars: ✭ 164 (-8.38%)
Mutual labels:  command-line
Mandown
man-page inspired Markdown viewer
Stars: ✭ 173 (-3.35%)
Mutual labels:  command-line
Demo
A framework for performing live pre-recorded command line demos in the wild 📼
Stars: ✭ 179 (+0%)
Mutual labels:  command-line
Cointop
A fast and lightweight interactive terminal based UI application for tracking cryptocurrencies 🚀
Stars: ✭ 2,912 (+1526.82%)
Mutual labels:  command-line
You Dont Need Gui
Stop relying on GUI; CLI **ROCKS**
Stars: ✭ 4,766 (+2562.57%)
Mutual labels:  command-line

cmt

Write consistent git commit messages based on a custom template.

Similar idea to commitizen, but with an emphasis on making it easy to define a custom commit style.

Demo

Concept

It's important to write consistent commit messages, but depending on the project you may well want to use different commit styles.

With cmt you create a .cmt file in your project directory. The .cmt file enforces a particular style of commit message for that project. You can also add predefined commit messages for things like version bumps and updating the readme.

For example, for my programming projects I try to use a commit style similar to the AngularJS Commit Message Guidelines. However, this isn't appropriate for my teaching notes repos or for my capistrano build repos.

Format

A .cmt file consist of two parts: the input parts and the output format.

A basic .cmt file to include a subject and body would look like:

# The input parts
{
    "Subject" = @ # Single line input
    "Body" = [email protected] # Multi-line input
}

# predefined commit messages
# this section is optional
{
    vb = "version bump"
}

# The output format
${Subject}

${Body}

A more complex example, the AngularJS Commit Message Guidelines:

# The input parts
{
    # Shows a list of options
    "Type" = [
        "feat",
        "fix",
        "docs",
        "style",
        "refactor",
        "test",
        "chore"
    ]
    "Scope" = @ # Single line input
    "Subject" = @
    "Body" = [email protected] # Multi-line input
    "Footer" = [email protected]
}

# predefined messages
# this section is optional
{
    vb = "chore: version bump"
    readme = "docs: updated readme"
}

# The output format
# Takes the values provided from the input stage
# and interpolates them in
${Type} (${Scope}): ${Subject}

${Body}

${Footer}

For my capistrano build repos the .cmt file is simply:

{}

"latest build"

Input Parts

These are at the top of the .cmt file and surrounded by opening and closing curly braces. A consist of a name and a type:

  • @: single line input
  • [email protected]: multi line input
  • %: select from a list of staged files
  • ["option 1", "option 2"]: list of options

Predefined Messages

The predefined messages section is optional. You can provide a list of names and messages and then use the -p <name> command-line argument to use one of them.

For example, with the following config, cmt -p vb would use the message "version bump".

vb = "version bump"

Predefined messages can also use any input parts defined in the prior section. An example of this would be:

{
    "Project" = [
        "ghc",
        "cabal"
    ]
}
{
    vb = "${Project}: version bump"
}

Running cmt -p vb will now prompt you to select which project is getting version bumped.

Output Format

The output format consists of named input parts (${<name>}) plus anything else you want.

Wildcard Output

You can accept an output called ${*}, which will add in whatever is passed to cmt as command-line arguments.

For example:

# Input parts
# * input not needed, as comes from command-line
{
    "Scope" = %
}

# Scope from input and * from command-line
(${Scope}): ${*}

Then use with:

cmt "Blah blah blah"

Usage

Add a .cmt file to your project directory.

cmt # will show the options and then commit

cmt will also look in your home directory if a .cmt file isn't found in the project directory hierarchy. This can be used to define a global commit style, which you can then override on a per-project basis.

Predefined Messages

If there are commit message you use frequently (such as "version bump"), you can setup predefined messages with aliases:

cmt -p vb # use the version bump message

Wildcard Output

If you're using the ${*} format option then:

cmt "blah blah blah" # this will go in ${*} place

Dry Runs

If you add --dry-run as the first argument, cmt will show you the output, but not try and make a commit. It will store the output so you can easily run it without having to re-enter everything.

cmt --dry-run "Blah blah blah"
cmt --dry-run -p vb

Re-run Failed/Dry Run Commits

If the commit returns with a non-zero status code or you run with --dry-run, your previous commit message is stored in a .cmt.bkp file. You can re-run the commit when you're ready with:

cmt --prev

Colour Output

By default the output uses bash colour codes. You can turn this off using the --no-color setting.

Other Options

cmt -h # displays usage information
cmt -v # displays version number
cmt -c # displays location of .cmt file

Install

Homebrew (Mac)

You can install cmt on your Mac using Homebrew:

brew install cmt

Debian/Ubuntu

A .deb package is available for Debian/Ubuntu. Download it and install with dpkg -i <package-name>.

Binaries

Binaries for Mac and Linux are available. Add the binary to a directory in your path (such as /usr/local/bin).

Cabal

Requirements: Cabal

cabal install cmt

Make sure you run cabal update first if you haven't run it recently.

Building

Requirements: Stack

The following command will build cmt and then install it in ~/.local/bin:

stack build && stack install
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].