GithubHelp home page GithubHelp logo

klak's Introduction

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 [email protected]

klak's People

Contributors

aubricus avatar pyup-bot avatar

Stargazers

Carlos Eduardo Sanchez Torres (sanchezcarlosjr) avatar Nik Kantar avatar

Watchers

 avatar James Cloos avatar

klak's Issues

Docs are failing to build.

  • Klak version: 0.4.3
  • Python version: N/A
  • Operating System: N/A

Description

Seems like docs are failing.

Shell does not work as expected with some CLI

  • Klak version: Latest
  • Python version: 3.6
  • Operating System: MacOS 10.13.5

Description

Using heroku CLI sometimes hangs when using shell.

What I Did

Commands work as expected when using subprocess.check_output(..., shell=True)

ModuleNotFoundError: No module named 'toml'

  • Klak version: 0.4.1
  • Python version: 3.7.3
  • Operating System: OSX 10.14.5

Description

Installed Klak and ran klak and received the error.

What I Did

Here's the traceback.

Traceback (most recent call last):
  File "/Users/aubreytaylor/Repos/cookiecutter/cookiecutter-djangocms/.venv/bin/klak", line 6, in <module>
    from klak.cli import main
  File "/Users/aubreytaylor/Repos/cookiecutter/cookiecutter-djangocms/.venv/lib/python3.7/site-packages/klak/cli.py", line 6, in <module>
    from .klak import import_clickfile, get_version
  File "/Users/aubreytaylor/Repos/cookiecutter/cookiecutter-djangocms/.venv/lib/python3.7/site-packages/klak/klak.py", line 5, in <module>
    import toml
ModuleNotFoundError: No module named 'toml'

Note: Installing toml locally fixed the issue; but should be installed when klak is installed.

Add Docs for Bumpversion

Probably need to add these to CONTRIBUTING.md.

Here's the flow:

# part can be major, minor, patch
bumpversion [part]

# see what changed
git diff head^

# see new tag
git tags

# if you need to push and track a new branch
git push -u origin $(git rev-parse --abbrev-ref HEAD)

# push up tags also
git push tags

Klak --version fails

  • Klak version: 0.4.2
  • Python version: 3.6.x
  • Operating System: OSX

Description

Running klak --version returns an error.

Could not read pyproject.toml to determine version.
Unknown

Enable Clickfile to Import Modules

It would be nice if we could break Clickfile tasks into their own files. I think right now, the way the Clickfile is imported is making this diffcult to enable. Need to look into this.

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.