Skip to main content

A CLI tool for generating project files

Project description

SuperFast CLI Tool

This CLI tool is designed for generating common file types used in FastAPI projects, such as controllers, models, services, and entities.

Installation

Installation

You can install the CLI tool via pip:

pip install superfast-cli

Usage

Generate files based on file type and class name:

fast create FILE_TYPE CLASS_NAME [--directory DIRECTORY]
Arguments:
  • FILE_TYPE - The type of file to generate. Valid values are:
    • controller: Creates a controller file.
    • model: Creates a model file.
    • service: Creates a service file.
    • entity: Creates an entity file.
    • res: Creates all file types (controller, model, service, and entity).
  • CLASS_NAME - The name of the class to generate the file for.
  • Options: -d, --directory - Directory to create the file in. Default is the current directory.

Example

Controller

Creates a controller.py file in the current location. You can also specify a location:

fast create controller MyController
fast create controller MyController --directory app/category

Generated File: controller.py

from fastapi import APIRouter

router = APIRouter()

@router.get("/")
async def get_items():
    # Implement your logic here
    pass

@router.post("/")
async def create_item():
    # Implement your logic here
    pass

Model

Creates an model.py file:

fast create model Category
fast create model Category --directory app/category

Generated File: model.py

from pydantic import BaseModel

class CategoryModel(BaseModel):
    id: int
    name: str
    description: str

Entity

Creates an entity.py file:

fast create entity Category
fast create entity Category --directory app/category

Generated File: entity.py

# entity.py
from sqlalchemy import Column, Integer, String
from database import Base

class CategoryEntity(Base):
    __tablename__ = "category"

    id = Column(Integer, primary_key=True, index=True, autoincrement=True)
    name = Column(String, index=True)

Service

Creates an service.py file:

fast create Service Category
fast create service Category --directory app/category

Generated File: service.py

# service.py
from sqlalchemy.orm import Session
from fastapi import Depends
from database import get_db


class CategoryService:
    def __init__(self, db: Session):
        self.db = db


def get_category_service(db: Session = Depends(get_db)) -> CategoryService:
    return CategoryService(db=db)

Resource

Creates all file types (controller.py, model.py, service.py, and entity.py):

fast create res Category
fast create res Category --directory app/category

Generated Files

- controller.py
- service.py
- model.py
- entity.py

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

superfast_cli-0.1.1.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

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

superfast_cli-0.1.1-py3-none-any.whl (2.3 kB view details)

Uploaded Python 3

File details

Details for the file superfast_cli-0.1.1.tar.gz.

File metadata

  • Download URL: superfast_cli-0.1.1.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for superfast_cli-0.1.1.tar.gz
Algorithm Hash digest
SHA256 64bc2811336640ffc62a67b76322d65c542a0b12d637e1adf89a9c7df8a402f3
MD5 5e083f1a863a766b326f36b94b0e5ca9
BLAKE2b-256 372545ad89225ffedb87bbf4f0ae4e24928ac3529a46cb02570ec5efdad3ba42

See more details on using hashes here.

File details

Details for the file superfast_cli-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: superfast_cli-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 2.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for superfast_cli-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 90b59e1c38325a057475c109a3d206263721f99c42c5fb3c7ac0d440df621e57
MD5 0d144aabc7f411521226a3ff5f0be8a8
BLAKE2b-256 9167a13bc2bbdfe63dcc33939d8271eb8c78b4d5ae973eac5b953d6dc9e1aeb7

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