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.6.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.6-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: doguda-0.1.6.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.6.tar.gz
Algorithm Hash digest
SHA256 11ee20f8028ccb86c336fb64837e783925ecee23a778be186db4c6e85f2cc646
MD5 723f15fa6ca532b615a1b984a900a328
BLAKE2b-256 3f74df5299e35de7427955fcc66a0a5764d154f879cfea339c617eb382ca3a3e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: doguda-0.1.6-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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 0da08194b16e153ac9827800504ba444ad7f614ec43f52fba4d53b9d628f8147
MD5 d9f7d09fd49733a03c461254b15ed228
BLAKE2b-256 53998e742d2ebab20ac473d585bce3637be7f9223b642b743a9bfd412196af41

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