Update template go
This commit is contained in:
33
tools/generate.sh
Normal file
33
tools/generate.sh
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
# Handler Generator Script for Unix/Linux/Mac
|
||||
# Usage: ./generate.sh <handler-name> [methods]
|
||||
|
||||
set -e
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "Usage: $0 <handler-name> [methods]"
|
||||
echo "Example: $0 user get post put delete"
|
||||
echo "Methods: get, post, put, delete (optional, default: get post)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
HANDLER_NAME=$1
|
||||
shift
|
||||
|
||||
METHODS=$@
|
||||
if [ -z "$METHODS" ]; then
|
||||
METHODS="get post"
|
||||
fi
|
||||
|
||||
echo "Generating handler: $HANDLER_NAME with methods: $METHODS"
|
||||
echo
|
||||
|
||||
# Change to project root directory
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
# Run the generator
|
||||
go run tools/generate-handler.go "$HANDLER_NAME" $METHODS
|
||||
|
||||
echo
|
||||
echo "Handler generated successfully!"
|
||||
echo "Don't forget to run: swag init -g cmd/api/main.go"
|
||||
Reference in New Issue
Block a user