Skip to content

mk - Interactive Task Runner for Makefile(Taskfile.yml)

License

Notifications You must be signed in to change notification settings

orangekame3/mk

Repository files navigation

mk - Interactive Task Runner for Makefile (Taskfile)

Go Report Card GitHub release GitHub license

mk is a command-line interface (CLI) tool designed to interactively execute make commands from a Makefile (GNU Make) or tasks from a Taskfile.yml go-task. It provides a user-friendly interface to select and run predefined commands, making it easier to manage and execute build tasks.

mk

Features

  • Interactive Interface: Browse and select from available make commands using arrow keys or filter by typing.
  • Documentation: View the description of each command to understand its purpose and usage.
  • Vim like keybindings: Use j and k to navigate, Enter to execute, and q to quit.
  • Filtering: Quickly search for commands by typing part of the command name. check ? for help.
  • Remote Makefile: Load a Makefile from a remote URL and execute commands.
  • Any Local Makefile: Load a Makefile from any directory and execute commands.
  • Taskfile.yml Support: Load a Taskfile.yml from a remote URL or local path and execute tasks.

Installation

mk can be installed using the following methods:

Homebrew

brew install orangekame3/tap/mk

Go Install

go install github.com/orangekame3/mk@latest

Manual Installation

  1. Download the latest release from the Releases
  2. Extract the archive and navigate to the extracted directory.
  3. Move the mk binary to a directory in your PATH.
mv mk /usr/local/bin

Usage

Prepare a Makefile with predefined commands and descriptions. Each command should be documented using a comment starting with ## to provide a description of the command.

SHELL := bash
.SHELLFLAGS := -eu -o pipefail -c
.DEFAULT_GOAL := help

.PHONY: test fmt
## Run tests
test:
 go test ./...

## Format source code
fmt:
 go fmt ./...

or you can set MK_DESC_POSITION=side in your .bashrc or .zshrc to show the description on the right side of the command.

SHELL := bash
.SHELLFLAGS := -eu -o pipefail -c
.DEFAULT_GOAL := help

.PHONY: test fmt

test: ## Run tests
 go test ./...

fmt: ## Format source code
 go fmt ./...

Run mk in your terminal to start the interactive interface. Select a command using arrow keys or filter by typing part of the command name. Press Enter to execute the selected command.

mk

This will display a list of available commands from the Makefile. Use the arrow keys to navigate and select a command, then press Enter to execute it.

Options

mk supports the following options:

mk is a CLI tool for executing make commands interactively.

Usage:
  mk [flags]

Flags:
  -f, --file string   Specify an input file other than Makefile (URL is also supported)
  -h, --help          help for mk
  -t, --taskfile      Use Taskfile.yml instead of Makefile
  -v, --version       version for mk

Load Makefile from a Remote URL

Use the -f or --file flag to load a Makefile from a remote URL. This allows you to execute commands from a Makefile hosted on a remote server.

mk -f https://raw.githubusercontent.com/orangekame3/mk/main/Makefile

Note

command executed at current directory.

Load Makefile from a Local File

Use the -f or --file flag to load a Makefile from a local file. This allows you to execute commands from a Makefile located in any directory.

mk -f /path/to/Makefile

Note

command executed at path/to directory, and return to the original directory after the command is executed.

Load Taskfile

Prepare a Taskfile.yml with predefined tasks and descriptions.

version: 3
tasks:
  test:
    cmds:
      - go test ./...
    description: Run tests
  fmt:
    cmds:
      - go fmt ./...
    description: Format source code

Use the -t or --taskfile flag to load a Taskfile.yml instead of a Makefile. This allows you to execute tasks from a Taskfile.yml.

mk -t

Note

It is usefule set alias in your .bashrc or .zshrc like alias tk='mk -t'.

Contact For questions or feedback, please contact at @orangekame3

License

This project is licensed under the MIT License. See the LICENSE file for more information.

Acknowledgements

This project was inspired by fzf-make by @kyu08, make2help by @Songmu, and glow Thank you for the inspiration!

Author

👤 orangekame3