skillfed

autocommand

A library to create a command-line program from a function

autocommand v2.2.2 1.5M downloads/30d#3,862 on PyPI57
Copyleft license LGPLv3 DORMANT released

What it is and what it does

Autocommand is a decorator-based library that turns a Python function into a fully functional command-line program. It inspects the function's signature—parameters, type annotations, and defaults—and automatically builds an argparse parser that handles positional arguments, optional flags, type conversion, and help text. When the module is run as __main__, autocommand collects command-line arguments, validates them against the function signature, and executes the function with the parsed values.

The library handles common CLI patterns: trailing arguments via *args, boolean switches with automatic short flags, type coercion with validation, file arguments, and docstring-based help text. It eliminates boilerplate argparse setup for simple scripts, making it useful for quick command-line tools, utility scripts, and small applications where a full framework would be overkill.

Use it for:

  • Convert a utility function into a standalone script without writing argparse boilerplate.
  • Build simple command-line tools that accept typed arguments with automatic validation and help.
  • Create file processing scripts (cat, copy, filter) that read from stdin or file paths.
  • Prototype CLI applications where function signatures naturally map to command arguments.
  • Add command-line interfaces to existing Python functions with minimal code changes.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Autocommand converts a Python function into a command-line program by automatically generating an argparse parser from the function's signature, handling arguments, options, type conversion, and help text generation.

Yes, for simple scripts and utilities. Autocommand is mature, dependency-free, and solves a real problem—eliminating argparse boilerplate for straightforward CLI functions. Dormant maintenance is not a blocker for stable, feature-complete code, but consider it only for scripts where the function-to-CLI mapping is natural. For complex CLIs, subcommands, or plugins, use a more actively maintained framework.

Install

autocommand on PyPI

pip

pip install autocommand

uv

uv add autocommand

poetry

poetry add autocommand

Installing autocommand

Before you install

Low friction: pure Python wheel with no runtime dependencies. Maintenance is dormant—last release was 2022-11-18 and last commit 2024-04-04—but the package is marked Mature and has been stable since its 2015 release.

License in practice

Licensed under LGPLv3 (copyleft). Any derivative work or modification must be released under compatible terms; static linking or bundling may trigger copyleft obligations depending on how the package is integrated.

Quickstart

from autocommand import autocommand

@autocommand(__name__)
def echo(thing):
    print(thing)

# Run: python script.py hello

Requires Python 3.7 or later.

Verify before relying

  • Whether the package works correctly with Python versions beyond 3.7 despite no recent releases.
  • Whether dormant maintenance status affects real-world reliability for new projects.

Package facts

License LGPLv3 (copyleft)
Python support supports the current Python release (>=3.7)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance dormant — 1,365 days since the last release
Last repo commit
First released
Downloads 1,475,808/month — #3,862 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: autocommand-2.2.2-py3-none-any.whl

Development Status :: 6 - MatureIntended Audience :: DevelopersLicense :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)Programming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyTopic :: Software DevelopmentTopic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Python Modules

Tags

function to command lineargparse from function signatureautomatic cli generatorpython function as scriptdecorator command line toolcli argument parserfunction signature to args
cli-generationargparse-wrapperscript-automation

More Software Development packages