Skip to main content

Klak

pypi standard-readme compliant travis-ci docs docs

Klak provides the ergonoics of a project Makefile with the ease of Python and power of Click.

Table of Contents

Background

Makefiles provide a simple interface, make <command>, that is great for automating repetitive project tasks. Makefile syntax, however, is archaic, error-prone, and ill-suited for constructing modern, useful command-line interfaces.

Python, on the other hand, has wonderful syntax and is great for scripting. When Python is paired with Click constructing modern, useful command-line interfaces is easy!

Is there a way we can combine the power of Python and Click into a "Makefile like" experience?

Enter Klak.

Klak exposes a single entry-point—klak—which auto-loads a 100%, vanilla Python file called a Clickfile. All CLI is built using standard Python and Click, and all commands are available via: klak <command> (see Usage).

What is it good for?

Klak's purpose is to provide a convenient, single-file experince for automating repetitive project tasks. It does not, nor will it ever, intend to replace Make or Makefiles.

Install

Stable Release

# NOTE: This is the recommended method of installation.
pip install klak

From Source

Klak uses Poetry to manage depdencies and distribution (in lieu of setuptools).

# NOTE: Clone the public repository
git clone git://github.com/aubricus/klak

# NOTE: or download the tarball
curl  -OL https://github.com/aubricus/klak/tarball/master

# NOTE: Once the source is downloaded
poetry install

Usage

To get started with Klak create a Clickfile. Here's a simple Clickfile to get started:

"""
Example Clickfile.

NOTE: Set your editor's language mode to Python to
      enable syntax highlighting! :^)
"""

import logging
import click
from klak.cli import cli


log = logging.getLogger("Clickfile")


# -------------------------------------
# Examples
# -------------------------------------

# Example: Add a command.
@cli.command()
@click.argument("name")
def greet(name):
    """Greet someone."""
    click.secho(f"Hello, {name}")


# Example: Add a group and sub-command.
@cli.group()
def humans():
    """Humans command group."""
    pass


@humans.command(name="count")
def humans_count():
    """Count all the humans."""
    click.secho("Over 9000!!!")

NOTE: You can also organize commands into a python package in the same directory. See Klak/Pull/229.

Once your Clickfile is ready, access commands through klak.

$ klak --help

Support

This project is a hobby/passion project which I maintain in my own time.

Python

  • Python 3.5+

OS

  • Linux ✓
  • MacOS ✓
  • Windows ✘ (any volunteers?)

Maintainers

@aubricus

Contributing

See the contributing file!

PRs accepted!

Please note, if editing the README, please conform to the standard-readme specification.

License

MIT © 2018, 2019 aubricus@gmail.com

Release files for klak 0.4.3

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

Source distribution (sdist)

Source distribution for klak 0.4.3
File Size Uploaded
klak-0.4.3.tar.gz 5.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for klak 0.4.3
File Interpreter ABI Platform
klak-0.4.3-py3-none-any.whl Python 3 none any Details

Total release size: 10.7 kB

Release files / klak-0.4.3.tar.gz

Download URL klak-0.4.3.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
dbacf7dbe16eddfb90c7b07768631875069cc6e4ef940355948c37bfc889a782
BLAKE2b-256 checksum
How to use checksums
c10d5cc1f3a1eecbe41ffefc40e44a77da9574e98e844484de4f54fb93f94874
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.12.16 CPython/3.7.3 Darwin/18.6.0

Release files / klak-0.4.3-py3-none-any.whl

Download URL klak-0.4.3-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a652733a9eb465829b2896cbd670bf484bc9ada016e03c978a5b01c3243a8d51
BLAKE2b-256 checksum
How to use checksums
efb57a12bc85d244f5cbdf68d5815b8033a567c817e0601790815bc3fa3394cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.12.16 CPython/3.7.3 Darwin/18.6.0

Release history Release notifications | RSS feed

This release

0.4.3 This release

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

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