From 2f43e96904e8bf254a6a4e9fb3f5ea2622fbe07c Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Fri, 30 Aug 2024 12:21:09 +1200 Subject: [PATCH] =?UTF-8?q?feat:=20Project=20Started=20=F0=9F=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 4 +++- .goreleaser.yaml | 2 +- README.md | 12 ++++++------ cmd/clear.go | 12 ++++++------ cmd/config.go | 17 +++++++++-------- cmd/root.go | 10 +++++----- cmd/version.go | 4 ++-- cmd/where.go | 6 +++--- go.mod | 2 +- internal/app/meta.go | 2 +- internal/config/default.go | 22 +++++++++++++++++++++- internal/config/field.go | 4 ++-- internal/config/init.go | 6 +++--- internal/config/key/keys.go | 4 ++++ internal/logger/init.go | 6 +++--- internal/style/style.go | 2 +- internal/where/env.go | 2 +- internal/where/util.go | 2 +- internal/where/where.go | 2 +- main.go | 6 +++--- 20 files changed, 77 insertions(+), 50 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b60ccef..05084c1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,9 @@ jobs: go-version: '1.22' - name: Copy go-semantic-release plugins and release run: | - /usr/local/bin/semantic-release --version-file \ + /usr/local/bin/semantic-release \ + --allow-initial-development-versions \ + --version-file \ --changelog .generated-go-semantic-release-changelog.md \ --hooks goreleaser \ --provider=gitea diff --git a/.goreleaser.yaml b/.goreleaser.yaml index fde6eb3..7fe4568 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -11,7 +11,7 @@ builds: main: main.go ldflags: - -extldflags '-static' - - -s -w -X hub.cybercinch.nz/guisea/go-template/internal/app/meta.Version={{.Version}} + - -s -w -X hub.cybercinch.nz/guisea/gosqldump/internal/app/meta.Version={{.Version}} gitea_urls: api: https://hub.cybercinch.nz/api/v1 diff --git a/README.md b/README.md index 9f42556..b535c90 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Press this shiny green button on top Screenshot 2022-09-30 at 13 37 30 -Then you would probably want to rename go mod name from `hub.cybercinch.nz/guisea/go-template` to something else. +Then you would probably want to rename go mod name from `hub.cybercinch.nz/guisea/gosqldump` to something else. To do this you could use your IDE refactor features or run [just](https://github.com/casey/just) target. ```shell @@ -45,17 +45,17 @@ This will prompt you to type a new name and will replace every occurence of the ### Changing name of the app -Change the value of the constant `Name` at [internal/app/meta.go](https://hub.cybercinch.nz/guisea/go-template/src/branch/main/internal/app/meta.go) +Change the value of the constant `Name` at [internal/app/meta.go](https://hub.cybercinch.nz/guisea/gosqldump/src/branch/main/internal/app/meta.go) ### Changing config file format from TOML from YAML -Change the value of the constant `ConfigFormat` at [internal/config/init.go](https://hub.cybercinch.nz/guisea/go-template/src/branch/main/internal/config/init.go) +Change the value of the constant `ConfigFormat` at [internal/config/init.go](https://hub.cybercinch.nz/guisea/gosqldump/src/branch/main/internal/config/init.go) ### Declaring new config fields -Firstly, declare a field key name as a constant inside [internal/config/key/keys.go](https://hub.cybercinch.nz/guisea/go-template/src/branch/main/internal/config/key/keys.go) +Firstly, declare a field key name as a constant inside [internal/config/key/keys.go](https://hub.cybercinch.nz/guisea/gosqldump/src/branch/main/internal/config/key/keys.go) -Then put them inside [config/default.go](https://hub.cybercinch.nz/guisea/go-template/src/branch/main/internal/config/default.go) (take a predefined fields for logging as a reference) +Then put them inside [config/default.go](https://hub.cybercinch.nz/guisea/gosqldump/src/branch/main/internal/config/default.go) (take a predefined fields for logging as a reference) For example @@ -82,4 +82,4 @@ For the example above it would be `viper.GetString(key.EmojiType)`. See [viper]( ## Something is not clear? -Please, [open an issue](https://hub.cybercinch.nz/guisea/go-template/issues/new) so I could document it +Please, [open an issue](https://hub.cybercinch.nz/guisea/gosqldump/issues/new) so I could document it diff --git a/cmd/clear.go b/cmd/clear.go index c1f6f1b..a6b2704 100644 --- a/cmd/clear.go +++ b/cmd/clear.go @@ -6,12 +6,12 @@ import ( "github.com/samber/lo" "github.com/spf13/cobra" - "hub.cybercinch.nz/guisea/go-template/internal/app" - "hub.cybercinch.nz/guisea/go-template/internal/color" - "hub.cybercinch.nz/guisea/go-template/internal/filesystem" - "hub.cybercinch.nz/guisea/go-template/internal/icon" - "hub.cybercinch.nz/guisea/go-template/internal/util" - "hub.cybercinch.nz/guisea/go-template/internal/where" + "hub.cybercinch.nz/guisea/gosqldump/internal/app" + "hub.cybercinch.nz/guisea/gosqldump/internal/color" + "hub.cybercinch.nz/guisea/gosqldump/internal/filesystem" + "hub.cybercinch.nz/guisea/gosqldump/internal/icon" + "hub.cybercinch.nz/guisea/gosqldump/internal/util" + "hub.cybercinch.nz/guisea/gosqldump/internal/where" ) type clearTarget struct { diff --git a/cmd/config.go b/cmd/config.go index f7f7088..0e7102f 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -3,6 +3,7 @@ package cmd import ( "errors" "fmt" + "github.com/charmbracelet/log" "os" "path/filepath" "slices" @@ -11,19 +12,19 @@ import ( "unsafe" "github.com/charmbracelet/lipgloss" - "hub.cybercinch.nz/guisea/go-template/internal/style" + "hub.cybercinch.nz/guisea/gosqldump/internal/style" - "hub.cybercinch.nz/guisea/go-template/internal/app" + "hub.cybercinch.nz/guisea/gosqldump/internal/app" levenshtein "github.com/ka-weihe/fast-levenshtein" "github.com/samber/lo" "github.com/spf13/cobra" "github.com/spf13/viper" - "hub.cybercinch.nz/guisea/go-template/internal/color" - "hub.cybercinch.nz/guisea/go-template/internal/config" - "hub.cybercinch.nz/guisea/go-template/internal/filesystem" - "hub.cybercinch.nz/guisea/go-template/internal/icon" - "hub.cybercinch.nz/guisea/go-template/internal/where" + "hub.cybercinch.nz/guisea/gosqldump/internal/color" + "hub.cybercinch.nz/guisea/gosqldump/internal/config" + "hub.cybercinch.nz/guisea/gosqldump/internal/filesystem" + "hub.cybercinch.nz/guisea/gosqldump/internal/icon" + "hub.cybercinch.nz/guisea/gosqldump/internal/where" ) // errUnknownKey will generate error for key that was not found and will provide a hint @@ -127,7 +128,6 @@ var configSetCmd = &cobra.Command{ if err != nil { handleErr(fmt.Errorf("invalid integer value: %s", value)) } - v = int(parsedInt) case bool: parsedBool, err := strconv.ParseBool(value) @@ -136,6 +136,7 @@ var configSetCmd = &cobra.Command{ } v = parsedBool + log.Debug("Parsed Bool Value: %v", parsedBool) } write: diff --git a/cmd/root.go b/cmd/root.go index ebed51e..2455bdf 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -3,17 +3,17 @@ package cmd import ( "fmt" "github.com/charmbracelet/log" - "hub.cybercinch.nz/guisea/go-template/internal/style" + "hub.cybercinch.nz/guisea/gosqldump/internal/style" "os" "strings" cc "github.com/ivanpirog/coloredcobra" "github.com/samber/lo" "github.com/spf13/cobra" - "hub.cybercinch.nz/guisea/go-template/internal/app" - "hub.cybercinch.nz/guisea/go-template/internal/filesystem" - "hub.cybercinch.nz/guisea/go-template/internal/icon" - "hub.cybercinch.nz/guisea/go-template/internal/where" + "hub.cybercinch.nz/guisea/gosqldump/internal/app" + "hub.cybercinch.nz/guisea/gosqldump/internal/filesystem" + "hub.cybercinch.nz/guisea/gosqldump/internal/icon" + "hub.cybercinch.nz/guisea/gosqldump/internal/where" ) func init() { diff --git a/cmd/version.go b/cmd/version.go index 0acde85..4fff36b 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -6,8 +6,8 @@ import ( "runtime" "github.com/samber/lo" - "hub.cybercinch.nz/guisea/go-template/internal/app" - "hub.cybercinch.nz/guisea/go-template/internal/color" + "hub.cybercinch.nz/guisea/gosqldump/internal/app" + "hub.cybercinch.nz/guisea/gosqldump/internal/color" "github.com/spf13/cobra" ) diff --git a/cmd/where.go b/cmd/where.go index fb5f4b1..cb809b1 100644 --- a/cmd/where.go +++ b/cmd/where.go @@ -6,9 +6,9 @@ import ( "github.com/samber/lo" "github.com/spf13/cobra" - "hub.cybercinch.nz/guisea/go-template/internal/app" - "hub.cybercinch.nz/guisea/go-template/internal/color" - "hub.cybercinch.nz/guisea/go-template/internal/where" + "hub.cybercinch.nz/guisea/gosqldump/internal/app" + "hub.cybercinch.nz/guisea/gosqldump/internal/color" + "hub.cybercinch.nz/guisea/gosqldump/internal/where" ) type whereTarget struct { diff --git a/go.mod b/go.mod index 7b8c89a..c9e4b55 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module hub.cybercinch.nz/guisea/go-template +module hub.cybercinch.nz/guisea/gosqldump go 1.22.1 diff --git a/internal/app/meta.go b/internal/app/meta.go index 1376785..bdaea41 100644 --- a/internal/app/meta.go +++ b/internal/app/meta.go @@ -5,7 +5,7 @@ const Version = "0.0.1" const ( // App is the name of the application - Name = "app" + Name = "gosqldump" // DescriptionShort short description of the app DescriptionShort = Name + " description" diff --git a/internal/config/default.go b/internal/config/default.go index c185df7..3e18421 100644 --- a/internal/config/default.go +++ b/internal/config/default.go @@ -2,7 +2,7 @@ package config import ( "github.com/spf13/viper" - "hub.cybercinch.nz/guisea/go-template/internal/config/key" + "hub.cybercinch.nz/guisea/gosqldump/internal/config/key" ) // fields is the config fields with their default values and descriptions @@ -25,6 +25,26 @@ fatal, error, warn, info, debug`, false, "Whether the logger should report the caller location.", }, + { + Key: key.MySQLHost, + DefaultValue: "localhost", + Description: "The MySQL/MariaDB hostname", + }, + { + Key: key.MySQLPort, + DefaultValue: 3306, + Description: "The MySQL/MariaDB Port to Connect to", + }, + { + Key: key.MySQLUser, + DefaultValue: "~", + Description: "The MySQL/MariaDB Username to connect with", + }, + { + Key: key.MySQLPassword, + DefaultValue: "~", + Description: "The MySQL/MariaDB Password to connect with", + }, //{ // key.TenantId, // "some_client_id", diff --git a/internal/config/field.go b/internal/config/field.go index a9e633a..fa9918a 100644 --- a/internal/config/field.go +++ b/internal/config/field.go @@ -11,9 +11,9 @@ import ( "github.com/samber/lo" "github.com/spf13/viper" - "hub.cybercinch.nz/guisea/go-template/internal/app" + "hub.cybercinch.nz/guisea/gosqldump/internal/app" - "hub.cybercinch.nz/guisea/go-template/internal/color" + "hub.cybercinch.nz/guisea/gosqldump/internal/color" ) type Field struct { diff --git a/internal/config/init.go b/internal/config/init.go index 4b8b64e..1bda472 100644 --- a/internal/config/init.go +++ b/internal/config/init.go @@ -4,9 +4,9 @@ import ( "strings" "github.com/spf13/viper" - "hub.cybercinch.nz/guisea/go-template/internal/app" - "hub.cybercinch.nz/guisea/go-template/internal/filesystem" - "hub.cybercinch.nz/guisea/go-template/internal/where" + "hub.cybercinch.nz/guisea/gosqldump/internal/app" + "hub.cybercinch.nz/guisea/gosqldump/internal/filesystem" + "hub.cybercinch.nz/guisea/gosqldump/internal/where" ) // ConfigFormat is the format of the config file diff --git a/internal/config/key/keys.go b/internal/config/key/keys.go index e1ba200..0348ca1 100644 --- a/internal/config/key/keys.go +++ b/internal/config/key/keys.go @@ -4,4 +4,8 @@ const ( LogsWrite = "logs.write" LogsLevel = "logs.level" LogsReportCaller = "logs.show_caller" + MySQLUser = "mysql.user" + MySQLPassword = "mysql.password" + MySQLHost = "mysql.host" + MySQLPort = "mysql.port" ) diff --git a/internal/logger/init.go b/internal/logger/init.go index 56021f1..687c7e0 100644 --- a/internal/logger/init.go +++ b/internal/logger/init.go @@ -5,14 +5,14 @@ import ( "fmt" "github.com/charmbracelet/log" "github.com/spf13/viper" - "hub.cybercinch.nz/guisea/go-template/internal/config/key" + "hub.cybercinch.nz/guisea/gosqldump/internal/config/key" "os" "path/filepath" "time" "github.com/samber/lo" - "hub.cybercinch.nz/guisea/go-template/internal/filesystem" - "hub.cybercinch.nz/guisea/go-template/internal/where" + "hub.cybercinch.nz/guisea/gosqldump/internal/filesystem" + "hub.cybercinch.nz/guisea/gosqldump/internal/where" ) func Init() error { diff --git a/internal/style/style.go b/internal/style/style.go index 56e466d..44dc579 100644 --- a/internal/style/style.go +++ b/internal/style/style.go @@ -2,7 +2,7 @@ package style import ( "github.com/charmbracelet/lipgloss" - "hub.cybercinch.nz/guisea/go-template/internal/color" + "hub.cybercinch.nz/guisea/gosqldump/internal/color" ) var ( diff --git a/internal/where/env.go b/internal/where/env.go index 7ba68a4..e4ef062 100644 --- a/internal/where/env.go +++ b/internal/where/env.go @@ -3,7 +3,7 @@ package where import ( "strings" - "hub.cybercinch.nz/guisea/go-template/internal/app" + "hub.cybercinch.nz/guisea/gosqldump/internal/app" ) // EnvConfigPath is the environment variable name for the config path diff --git a/internal/where/util.go b/internal/where/util.go index 853241f..5c0033c 100644 --- a/internal/where/util.go +++ b/internal/where/util.go @@ -2,7 +2,7 @@ package where import ( "github.com/samber/lo" - "hub.cybercinch.nz/guisea/go-template/internal/filesystem" + "hub.cybercinch.nz/guisea/gosqldump/internal/filesystem" "os" ) diff --git a/internal/where/where.go b/internal/where/where.go index 86ee94f..d021a85 100644 --- a/internal/where/where.go +++ b/internal/where/where.go @@ -5,7 +5,7 @@ import ( "path/filepath" "runtime" - "hub.cybercinch.nz/guisea/go-template/internal/app" + "hub.cybercinch.nz/guisea/gosqldump/internal/app" ) func home() string { diff --git a/main.go b/main.go index 1fae8c4..e43d09e 100644 --- a/main.go +++ b/main.go @@ -3,9 +3,9 @@ package main import ( "github.com/charmbracelet/log" "github.com/samber/lo" - "hub.cybercinch.nz/guisea/go-template/cmd" - "hub.cybercinch.nz/guisea/go-template/internal/config" - "hub.cybercinch.nz/guisea/go-template/internal/logger" + "hub.cybercinch.nz/guisea/gosqldump/cmd" + "hub.cybercinch.nz/guisea/gosqldump/internal/config" + "hub.cybercinch.nz/guisea/gosqldump/internal/logger" "os" )