cmd

package
v0.1.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Copyright © 2023 Rohit Singh rkochhar@uwaterloo.ca

Copyright © 2023 Rohit Singh rkochhar@uwaterloo.ca

Copyright © 2023 Rohit Singh rkochhar@uwaterloo.ca

Index

Constants

This section is empty.

Variables

View Source
var DOCKERFILE_BASE = `` /* 654-byte string literal not displayed */
View Source
var DOCKER_COMPOSE_BASE = `version: "3.9"

services:
  server:
    image: server
    build: .
    ports:
      - "4000:4000"
`
View Source
var HANDERS_BASE = `` /* 501-byte string literal not displayed */
View Source
var HANDLERS_TEST_BASE = `` /* 1685-byte string literal not displayed */
View Source
var MAIN_BASE = `` /* 1541-byte string literal not displayed */

Functions

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func GenerateContainerizationFiles

func GenerateContainerizationFiles(target string) error

Creates Dockerfile and docker-compose.yaml

func GenerateGoSourceFiles

func GenerateGoSourceFiles(target string) error

Creates main.go, handlers.go and handlers_test.go

func GetGolangPackage

func GetGolangPackage(target string, packageName string) error

Executes `go mod download`

func ScaffoldProject

func ScaffoldProject(target string, folders [][]string, readme *os.File) error

Scaffolds the project file structure and templates README documentation

func TemplateFile

func TemplateFile(target string, newFile string, templateFile string) error

Templates a new file from an existing one

Types

type Config

type Config interface {
	// contains filtered or unexported methods
}

Config interface must contain app information collected from command flags or YAML file

type EndpointDefinition

type EndpointDefinition struct {
	Path        string `yaml:"path"`
	Method      string `yaml:"method"`
	Description string `yaml:"description"`
	// contains filtered or unexported fields
}

EndpointDefinition contains information about custom endpoints defined in YAML configuration files

func (*EndpointDefinition) GenerateHandlerFunction

func (e *EndpointDefinition) GenerateHandlerFunction() string

Returns a templated string describing a handler function for the given endpoint

func (*EndpointDefinition) GenerateReadmeTableEntry

func (e *EndpointDefinition) GenerateReadmeTableEntry() string

Returns a templated string to append to README.md API Endpoint table

func (*EndpointDefinition) GenerateRouterAttachment

func (e *EndpointDefinition) GenerateRouterAttachment() string

Returns a templated line of code attaching handler function to path via router

type FlagConfig

type FlagConfig struct {
	AppName   string
	Directory string
	ModName   string
}

FlagConfig contains app information collected from command line flags

type YamlConfig

type YamlConfig struct {
	AppName   string               `yaml:"appName"`
	Directory string               `yaml:"directory"`
	ModName   string               `yaml:"modName"`
	Endpoints []EndpointDefinition `yaml:"endpoints"`
}

YamlConfig contains app information collected from YAML configuration file

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL