Skip to main content

A lightweight Python command runner

Project description

🍥️ dony

A lightweight Python command runner with shell execution and user interactions.

Installation

pip install dony

Optional dependencies:

brew install fzf     # For fuzzy selection
brew install shfmt   # For shell command formatting

Example

import dony

@dony.command(run_from="git_root")
def deploy():
    """Deploy application"""

    if not dony.confirm("Deploy to production?"):
        return

    env = dony.select("Select environment:", ["staging", "production"])

    dony.shell("npm run build")
    dony.shell("npm test")
    dony.shell(f"./deploy.sh {env}", confirm=True)

    dony.success(f"Deployed to {env}")

if __name__ == "__main__":
    deploy()

Run with python deploy.py

Things to know

  • Available directories to run from:
    • "current_dir" (default)
    • "git_root"
    • "command_file"
    • "temp_dir"
    • Custom path string
  • Available prompts based on questionary:
    • dony.input(): free-text entry
    • dony.confirm(): yes/no ([Y/n] or [y/N])
    • dony.select(): option picker (supports fuzzy)
    • dony.select_many(): multiple option picker (supports fuzzy)
    • dony.press_any_key(): pause until keypress
    • dony.echo(): styled text output
    • dony.error(): ✕ error message
    • dony.success(): ✓ success message

API Reference

def command(
    run_from: Union[str, Path, Literal[ "current_dir", "git_root", "command_file", "temp_dir"]] = "current_dir",
    verbose: bool = True,
): 
    ...

# Shell execution
def dony.shell(
    command: str,
    run_from: Optional[Union[str, Path]] = None,
    dry_run: bool = False,
    quiet: bool = False,
    capture_output: bool = True,
    abort_on_failure: bool = True,
    abort_on_unset_variable: bool = True,
    trace_execution: bool = False,
    show_command: bool = True,
    confirm: bool = False,
) -> str:
    ...


## License

MIT License

## Author

Mark Lidenberg [marklidenberg@gmail.com](mailto:marklidenberg@gmail.com)

Project details


Download files

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

Source Distribution

dony-0.3.1.tar.gz (48.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dony-0.3.1-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file dony-0.3.1.tar.gz.

File metadata

  • Download URL: dony-0.3.1.tar.gz
  • Upload date:
  • Size: 48.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.2

File hashes

Hashes for dony-0.3.1.tar.gz
Algorithm Hash digest
SHA256 a97cc122604ac60ea092863440c0d60849f905c09fd0fc0bd477eb605ab6b43f
MD5 6149150159807c072da42f6abde6b52b
BLAKE2b-256 912224eed9162eb69211057af3e9ad5c2146ee5d8dc361c7d4102dab4e57f2cf

See more details on using hashes here.

File details

Details for the file dony-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: dony-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 14.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.2

File hashes

Hashes for dony-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b04d6d20dacd383352111133e9cf5e7d6fd4150c2cb67051d938a8e26d4f74f4
MD5 fb2314b47a803107b686352f5626edef
BLAKE2b-256 a23821060902ad141316c7bd3aa64e35b95e956c29be983d243046154b08bb6c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page