This commit is contained in:
Darko Luketic 2024-08-19 13:54:46 +02:00
parent 7548c9a304
commit c2369cca8a
8 changed files with 60 additions and 14 deletions

View File

@ -1,7 +1,3 @@
/*
Copyright © 2024 Darko Luketic <info@icod.de>
*/
package cmd
import (
@ -10,18 +6,10 @@ import (
"github.com/spf13/cobra"
)
// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "accountserver",
Short: "A brief description of your application",
Long: `A longer description that spans multiple lines and likely contains
examples and usage of using your application. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
// Uncomment the following line if your bare application
// has an action associated with it:
// Run: func(cmd *cobra.Command, args []string) { },
@ -47,5 +35,3 @@ func init() {
// when this action is called directly.
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}

37
cmd/serve.go Normal file
View File

@ -0,0 +1,37 @@
package cmd
import (
"code.icod.de/auth/accountserver/configuration"
"github.com/spf13/cobra"
)
// serveCmd represents the serve command
var serveCmd = &cobra.Command{
Use: "serve",
Short: "Run the account server",
RunE: func(cmd *cobra.Command, args []string) error {
return nil
},
}
func init() {
rootCmd.AddCommand(serveCmd)
// Here you will define your flags and configuration settings.
serveCmd.Flags().BoolVar(&configuration.RunHTTP, "http", true, "Run http server")
serveCmd.Flags().BoolVar(&configuration.RunGRPC, "grpc", true, "Run grpc server")
serveCmd.Flags().StringVar(&configuration.SMTPHost, "smtp-host", "localhost", "SMTP host")
serveCmd.Flags().IntVar(&configuration.SMTPPort, "smtp-port", 587, "SMTP port")
serveCmd.Flags().StringVar(&configuration.SMTPUser, "smtp-user", "", "SMTP user")
serveCmd.Flags().StringVar(&configuration.SMTPPass, "smtp-pass", "", "SMTP password")
// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// serveCmd.PersistentFlags().String("foo", "", "A help for foo")
// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// serveCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}

6
configuration/app.go Normal file
View File

@ -0,0 +1,6 @@
package configuration
var (
RunHTTP = true
RunGRPC = true
)

8
configuration/mail.go Normal file
View File

@ -0,0 +1,8 @@
package configuration
var (
SMTPHost = "smtp.example.com"
SMTPPort = 587
SMTPUser = "admin"
SMTPPass = "admin"
)

2
go.mod
View File

@ -9,6 +9,8 @@ require (
)
require (
github.com/idc77/gomail v0.0.0-20240819113050-ac97008b42eb // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
)

5
go.sum
View File

@ -5,6 +5,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/idc77/gomail v0.0.0-20240819113050-ac97008b42eb h1:eoCCdEgNvIAO3+sb7drW2gV36JOkILxyJllfEUHoo1A=
github.com/idc77/gomail v0.0.0-20240819113050-ac97008b42eb/go.mod h1:iRMDvqBOUICvDAsSzKcIBfFLghLJ1EeXBe6tH7Mmv6U=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@ -16,6 +18,9 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk=
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/mail.v2 v2.3.1/go.mod h1:htwXN1Qh09vZJ1NVKxQqHPBaCBbzKhp5GzuJEA4VJWw=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

1
service/account.go Normal file
View File

@ -0,0 +1 @@
package service

1
service/email.go Normal file
View File

@ -0,0 +1 @@
package service