Skip to content
Snippets Groups Projects
Verified Commit 1297b8b2 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

chore: Refactor configuration setup and command execution

- Remove commented out code and unused code related to settings, configuration change event handling, and message and config endpoints
- Fix bug where error messages are not printed when there are configuration errors and verbose mode is disabled
- Update vendorSha256, ldflags, buildInputs, and description for the docman package in flake.nix
- Remove Database struct and add Verbose field to AppConfig struct in source/config/definition.go
- Refactor TestMaskCodeBlocks function in source/utils/strings_test.go
- Modify SetUp function in source/config/setup.go
- Update ConfigPath and remove Release command in CommandsStruct struct in source/command/definition.go
- Change variable assignment and add error handling, command line argument parsing, setup of configuration, and execution of commands in source/command/execute.go
- Add version parameter and disable DIRENV_ENABLED and DIRENV_TRUSTED in .idea/runConfigurations/go_build_gitlab_schukai_com_oss_utilities_documentation_manager.xml
parent 1ad639fb
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@
<configuration default="false" name="go build gitlab.schukai.com/oss/utilities/documentation-manager" type="GoApplicationRunConfiguration" factoryName="Go Application" nameIsGenerated="true">
<module name="documentation-manager" />
<working_directory value="$PROJECT_DIR$/" />
<parameters value="version" />
<EXTENSION ID="com.fapiko.jetbrains.plugins.better_direnv.runconfigs.GolandRunConfigurationExtension">
<option name="DIRENV_ENABLED" value="false" />
<option name="DIRENV_TRUSTED" value="false" />
......
......@@ -63,13 +63,9 @@
#vendorSha256 = "sha256-XdB+u94Rqsb29jVs4miyOq1NEYaVJHWFXg6QebFJzNQ=";
vendorSha256 = "sha256-81IBG8H1jsYKD+tmFeCpAWFdz6cuQDt9r+FV56xboBU=";
# "-X release.version=$version -X release.build=$(due --iso-8601 | tr -d "-" )"
ldflags = [
"-s"
"-w"
"-X release.version=1"
"-X release.build=2"
"-X release.version=${version}"
"-X release.build=${build}"
];
buildInputs = [ versionTool.defaultPackage.${system} ];
......
package command
type CommandsStruct struct {
ConfigPath string `long:"config" short:"c" description:"Path to configuration file"`
Release ReleaseCommand `command:"release" description:"Release commands"`
ConfigPath string `long:"config" short:"c" description:"Path to configuration file"`
Verbose bool `long:"verbose" short:"v" description:"Verbose output"`
Version struct {
} `command:"version" description:"Prints the version" call:"PrintReleaseInfo"`
}
//
//type Definition struct {
// Verbose bool `short:"v" long:"verbose" description:"Show verbose debug information"`
// ConfigurationPath string `short:"c" long:"config" description:"Path to the configuration file"`
// Version struct {
// } `command:"version" description:"Prints the version" call:"PrintVersion"`
// Document struct {
// } `command:"document" description:"Document related commands"`
// Server struct {
// } `command:"server" description:"Server related commands"`
//}
......@@ -16,7 +16,7 @@ var helpInfo = "\nYou can use the --help flag to get more information about the
func Execute() {
instance := xflags.New(os.Args[0], CommandsStruct{})
instance = xflags.New(os.Args[0], CommandsStruct{})
if instance.HasErrors() {
for _, msg := range instance.Errors() {
error2.PrintError(msg.Error())
......
......@@ -3,66 +3,3 @@ package config
func checkConstraints() bool {
return true
}
// func sanitizeMessageEndpoint() {
// //e := Instance.Client.Endpoints.Messages
// //
// //u, err := url.ParseRequestURI(e)
// //error2.CheckError(err)
// //
// //if u.Scheme != "ws" {
// // u.Scheme = "ws"
// //}
// //
// //if u.Host == "" {
// // u.Host = Instance.Server.Host
// // if u.Host == "" {
// // error2.PrintErrorAndExit("Invalid message endpoint: " + e)
// // }
// //}
// //
// //Instance.Client.Endpoints.Messages = u.String()
//
// }
//
// func sanitizeConfigEndpoint() {
// //e := Instance.Client.Endpoints.Config
// //
// //u, err := url.ParseRequestURI(e)
// //error2.CheckError(err)
// //
// //if u.Scheme != "http" {
// // u.Scheme = "http"
// //}
// //
// //if u.Host == "" {
// // u.Host = Instance.Server.Host
// // if u.Host == "" {
// // error2.PrintErrorAndExit("Invalid config endpoint: " + e)
// // }
// //}
// //
// //Instance.Client.Endpoints.Config = u.String()
//
// cfg := Instance.Config()
//
// e := cfg.Client.Endpoints.Config
//
// u, err := url.ParseRequestURI(e)
// error2.CheckError(err)
//
// if strings.HasPrefix(u.Scheme, "http") {
// u.Scheme = "http"
// }
//
// if u.Host == "" {
// u.Host = cfg.Server.Host
// if u.Host == "" {
// error2.PrintErrorAndExit("Invalid message endpoint: " + e)
// }
// }
//
// cfg.Client.Endpoints.Config = u.String()
// Instance.SetConfig(cfg)
//
// }
......@@ -3,8 +3,5 @@ package config
type Settings map[string]interface{}
type AppConfig struct {
Database struct {
// user:pass@tcp(127.0.0.1:3306)/alvine_platform?charset=utf8mb4&parseTime=True&loc=Local
DSN string `env:"DATABASE_DSN" yaml:"DSN"`
} `yaml:"Database"`
Verbose bool `env:"DATABASE_DSN" yaml:"DSN"`
}
......@@ -58,7 +58,7 @@ func SetUp(cfgPath string) {
//preparation.OnChange(once)
preparation.Import()
if preparation.HasErrors() {
if preparation.HasErrors() && Instance.Config().Verbose {
for _, msg := range preparation.Errors() {
error2.PrintError(msg.Error())
}
......
......@@ -4,10 +4,6 @@ package main
import "gitlab.schukai.com/oss/utilities/documentation-manager/command"
//var (
// settings *xflags.Settings[commands.Definition]
//)
func main() {
command.Execute()
......
......@@ -23,11 +23,7 @@ func TestMaskCodeBlocks(t *testing.T) {
for _, table := range tables {
//p, _ := os.Getwd()
_, p, _, _ := runtime.Caller(0)
// p = filepath.Dir(p) // go to parent directory
//p = filepath.Dir(p) // go to parent directory
//p = filepath.Dir(p) // go to parent directory
p = filepath.Dir(p) // go to parent directory
p = filepath.Join(p, table.input)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment