feat(init): Start implementing system config
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Matthieu 'JP' DERASSE 2022-08-04 10:39:24 +00:00
parent 8688baccb2
commit 48b1739576
Signed by: mderasse
GPG Key ID: 55141C777B16A705
5 changed files with 44 additions and 7 deletions

View File

@ -36,8 +36,8 @@ func (a APIType) GetInitializeUserInput(params *models.UserInputParams) (*models
params.GoModuleName = &goModulePath params.GoModuleName = &goModulePath
} }
log.Info("Do you want to enable database integration ?") log.Info("Do you want to enable database models auto generation ?")
params.DB = helpers.YesOrNoInput() params.DatabaseModels = helpers.YesOrNoInput()
return params, nil return params, nil
} }

22
helpers/config.go Normal file
View File

@ -0,0 +1,22 @@
package helpers
import (
"git.home.m-and-m.ovh/mderasse/gouick/helpers/models"
)
const configFile = ".gouick.yaml"
// ReadConfig will search the config file in the given path, read it and return a Config object
func ReadConfig(path string) (*models.Config, error) {
return nil, nil
}
// WriteConfig will write the new or updated config
func WriteConfig(path string, config *models.Config) error {
return nil
}
// WriteConfigFromUserInputParams
func WriteConfigFromUserInputParams(path string, userInput *models.UserInputParams) error {
return nil
}

View File

@ -1,4 +0,0 @@
// Package helpers contains all basic function that might make development easier / avoid code duplication
package helpers
const configFile = ".gouick.yaml"

19
helpers/models/config.go Normal file
View File

@ -0,0 +1,19 @@
package models
// Config structure represent the main configuration of the project.
type Config struct {
ProjectName string `yaml:"project_name"`
ProjectDescription string `yaml:"project_description"`
ProjectOwner string `yaml:"project_owner"`
Features FeaturesConfig `yaml:"features"`
}
// FeaturesConfig structure represent the configuration of all possible features.
type FeaturesConfig struct {
DatabaseModels DatabaseModelsConfig `yaml:"database_models"`
}
// DatabaseModelsConfig structure represent the configuration of the Database Models feature.
type DatabaseModelsConfig struct {
Enabled bool `yaml:"enabled"`
}

View File

@ -2,7 +2,7 @@ package models
// UserInputParams is a struct containing all fields that can be useful for project generation. // UserInputParams is a struct containing all fields that can be useful for project generation.
type UserInputParams struct { type UserInputParams struct {
DB bool DatabaseModels bool
GoModuleName *string GoModuleName *string
ProjectDescription string ProjectDescription string
ProjectDirectory string ProjectDirectory string