Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

a simple command runner

Project description


A simple command runner. To install (add sudo if necessary)

python3 -m pip install volkanic


List sub-commands

$ volk
availabe commands:
- a
- o
- runconf
- where

Locate a Python package directory with volk where:

$ volk where requests
requests	/usr/local/lib/python3.6/site-packages/requests

You can open a file or URL with default application with volk o.

To open current directory with default file manager (Finder / explorer.exe / ...)

$ volk o .

Show sys.argv:

$ volk a \; "hello world" hello python
0	'/usr/local/bin/volk'
1	'a'
2	';'
3	'hello world'
4	'hello'
5	'python'

Sub-command protocal

Say you have a package named newpkg

├── docs
├── newpkg
│   ├──
│   ├──
│   ├──
│   ├──
│   └──
├── requirements.txt
└── test_newpkg

In one of your functional modules, e.g. newpkg/newpkg/, provide a entry function which takes exactly 2 arguments:

import argparse

def format_text(path):
    # actual code here

def run(prog=None, args=None):
    desc = 'human readable formatter'
    parser = argparse.ArgumentParser(prog=prog, description=desc)
    parser.add_argument('-i', '--input-file', help='path to your input file')
    ns = parser.parse_args(args)

Sub-command registry in newpkg/newpkg/

import volkanic

entries = {
    # shorthand for "newpkg.formatter:run": "fmt",
    "newpkg.formatter": "fmt",
    "newpkg.parsers:run_yml_parser": "yml",
    "newpkg.parsers:run_ini_parser": "ini",
registry = volkanic.CommandRegistry(entries)

Note that newpkg.formatter is a shorthand for newpkg.formatter:run.

Configure top-command in newpkg/

from setuptools import setup

    entry_points={"console_scripts": ["newcmd = newpkg.main:registry"]},
    # more arguments

Install package newpkg or link with python3 develop.

Now you have command newcmd:

$ newcmd
availabe commands:
- fmt
- ini
- yml

Run with sub-command fmt:

$ newcmd fmt -h


Create a YAML file, e.g. print.yml

    module: builtins
    call: print
    - volkanic
    - command
        sep: "-"
        end: "~"


$ volk runconf print.yml

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for volkanic, version 0.0.7
Filename, size File type Python version Upload date Hashes
Filename, size volkanic-0.0.7.tar.gz (5.1 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page