Skip to main content

Turn Python functions into CLI commands and HTTP endpoints instantly

Project description

Doguda

Turn Python functions into CLI commands and HTTP endpoints instantly.

PyPI version Python 3.10+ License: MIT

Installation

pip install doguda

Quick Start

Create a file (e.g., my_commands.py):

from doguda import DogudaApp

app = DogudaApp("MyCommands")

@app.command
def hello(name: str = "World") -> str:
    """Say hello to someone."""
    return f"Hello, {name}!"

@app.command
async def add(a: int, b: int) -> int:
    """Add two numbers."""
    return a + b

CLI Usage

Ensure your module is in the current directory or DOGUDA_PATH.

Run commands directly from the command line:

# Execute a command (automatically discovered)
doguda exec hello --name "Doguda"
# Output: Hello, Doguda!

doguda exec add --a 2 --b 3
# Output: 5

List Available Commands

doguda list

Output:

📦 MyCommands
  • hello(name: str)
      Say hello to someone.
  • add(a: int, b: int)
      Add two numbers.

HTTP Server

Start a FastAPI server with your commands as endpoints:

doguda serve --host 0.0.0.0 --port 8000

Then call your functions via HTTP:

curl -X POST http://localhost:8000/v1/doguda/hello \
  -H "Content-Type: application/json" \
  -d '{"name": "Doguda"}'

Organizing Commands

You can split your commands across multiple files. Valid DogudaApp instances with the same name will be automatically merged into a single logical app in the CLI.

# users.py
app = DogudaApp("Backend") # Same name

# reports.py
app = DogudaApp("Backend") # Same name

When running doguda list, these will appear unified under 📦 Backend.

Environment Variables

Variable Description Default
DOGUDA_PATH Path to search for modules Current directory

Response Models

Use Pydantic models for structured responses:

from pydantic import BaseModel
from doguda import DogudaApp

app = DogudaApp()

class UserResponse(BaseModel):
    id: int
    name: str
    email: str

@app.command
def get_user(user_id: int) -> UserResponse:
    """Get user by ID."""
    return UserResponse(id=user_id, name="John", email="john@example.com")

License

MIT License - see LICENSE for details.

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

doguda-0.1.8.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

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

doguda-0.1.8-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file doguda-0.1.8.tar.gz.

File metadata

  • Download URL: doguda-0.1.8.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for doguda-0.1.8.tar.gz
Algorithm Hash digest
SHA256 8d11e501cd11cb5f08bbaf175804569a64720307df90000d19058d27bc3e6125
MD5 71f3ed7a817d2df4e73ee05796791c90
BLAKE2b-256 f6c32e784a6a439248d935673d391551b91e66b4665833d9ef129c8f13fa7205

See more details on using hashes here.

File details

Details for the file doguda-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: doguda-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for doguda-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 7cd548164f861aa9d96dc6befe757399ba44f4d43d47e36d147965abd6aa59f6
MD5 64bed03cd8ccf8d07f85ae167698374b
BLAKE2b-256 1ddea07cf590e57733f950e676befa17054f311c3974fdaef86433fb08197e81

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