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.2.tar.gz (10.9 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.2-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: doguda-0.1.2.tar.gz
  • Upload date:
  • Size: 10.9 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.2.tar.gz
Algorithm Hash digest
SHA256 7631d253910e3466cd7f516390b5724f815649c2c0bc7069c0d731cba53d86a2
MD5 861e28e1debe4a18f35165bdf001cd60
BLAKE2b-256 50f784cbc8cf1224422b43d738f9e8367297cd65445d6f1ce62047f6bc52d0c2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: doguda-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.4 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f44311b9446462414d233a1dfc5cb72a9437e3628c7f580e163a9857b1865603
MD5 a65f097ce7146a2949fd0f6d720af937
BLAKE2b-256 2c9951e303937b0fa7208aa48af59bfe452a48237d3f5902fce40e17aa5157a8

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