erbuilder

command module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2020 License: MIT Imports: 1 Imported by: 0

README

erbuilder

version golang-version master-actions Actions Status GoDoc Go Report Card

The purpose of this tool is to parse a file or a list of files containing the mappping against the database and generate an .er file describing the database modeling.

Installation

In order to be able to use this you simply have to :

go get -u github.com/Angelos-Giannis/erbuilder

Definition of commands

There is a command called generate which actually retrieves the details from the provided files or files under directory and generates the respective .er file based on the definition of the structs in those files.

NAME:
   main generate - Generate the .er file based on the provided structures.

USAGE:
   main generate [command options] [arguments...]

OPTIONS:
   --common_field value, -c value       Common field for all the tables which do not have the provided tag in place.
   --directory value, -d value          Directory to retrieve the files from.
   --file_list value, -l value          List of files to parse.
   --id_field value                     Id field to be used for all the tables.
   --output_filename value, --of value  Define the generated output filename (will be used for both the .er and the image file). (default: "er-diagram")
   --output_path value, -o value        The path were to store the .er file. (default: ".")
   --tag value, -t value                Tag value to consume from the structs. (default: "db")
   --title value                        Title to be included in the exported image. (default: "Database Schema")
   --help, -h                           show help (default: false)

How to use

To generate a new .er file with the database models, a command like the following needs to be executed :

erbuilder generate --directory "./test/" --output_path "./test/" --output_filename "example-er-diagram" --id_field "id" --tag "db" --title "example_db"

or by using go run in the root folder of the project :

go run main.go generate --directory "./test/" --output_path "./test/" --output_filename "example-er-diagram" --id_field "id" --tag "db" --title "example_db"

Documentation

Overview

Package erbuilder reads across a list of files and after retrieving the structs found in there, it generates a '.er' file based on a specific tag.

Installation can be done by running :

go get -u github.com/Angelos-Giannis/erbuilder

To use the tool and generate a .er file, the following command needs to be executed (change values accordingly) :

erbuilder generate --directory "./test/" --output_path "./test/" --output_filename "example-er-diagram" --id_field "id" --tag "db" --title "example_db"

Also, this can be used as an external package in any service. To use this tool as part of your project, you need to do something like the following :

import (
	"github.com/Angelos-Giannis/erbuilder/internal/app/service"
	"github.com/Angelos-Giannis/erbuilder/internal/domain"
)

func main() {
	// Specify your values for the options.
	options := domain.Options{
		Directory:      "./../../../test/",
		IDField:        "id",
		FileList:       cli.StringSlice{},
		OutputFilename: "test-example-er-diagram",
		OutputPath:     "./../../../test",
		Tag:            "db",
		Title:          "example_db",
	}
	actualService := service.New(options)
	_ = actualService.Generate()
}

For more details, please visit : https://github.com/Angelos-Giannis/erbuilder.

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

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