ajout config.yml
This commit is contained in:
parent
9985fc2dff
commit
23e372d025
@ -1,4 +1,4 @@
|
||||
package create
|
||||
package cmdCreate
|
||||
|
||||
import (
|
||||
"bytes"
|
@ -1,4 +1,4 @@
|
||||
package create
|
||||
package cmdCreate
|
||||
|
||||
import (
|
||||
"bufio"
|
38
cmdEnv/envVars.go
Normal file
38
cmdEnv/envVars.go
Normal file
@ -0,0 +1,38 @@
|
||||
package cmdEnv
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"kode-starter/config"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var EnvCmd = &cobra.Command{
|
||||
Use: "env",
|
||||
Short: "manage environment variables",
|
||||
Long: `A simple CLI option to manage environment variables`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
|
||||
config.SetInformations(cmd, args)
|
||||
|
||||
// if option --env or -e is set then print environment variables
|
||||
if envVariablesFlag {
|
||||
printEnvVariables()
|
||||
}
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
func printEnvVariables() {
|
||||
fmt.Println("Environment variables")
|
||||
fmt.Println("---------------------")
|
||||
|
||||
// loop over all environment variables
|
||||
for _, e := range os.Environ() {
|
||||
// split key and value
|
||||
pair := strings.Split(e, "=")
|
||||
fmt.Println(pair[0])
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package lists
|
||||
package cmdLists
|
||||
|
||||
import (
|
||||
"encoding/json"
|
3
config.yml
Normal file
3
config.yml
Normal file
@ -0,0 +1,3 @@
|
||||
version: "3"
|
||||
|
||||
category:
|
@ -38,6 +38,9 @@ var createDescription string
|
||||
|
||||
var createPrivatge string
|
||||
|
||||
// variables for env command
|
||||
var envVariablesFlag bool = false
|
||||
|
||||
func GetAuthor() string {
|
||||
return author
|
||||
}
|
||||
|
3
go.mod
3
go.mod
@ -3,6 +3,7 @@ module kode-starter
|
||||
go 1.20
|
||||
|
||||
require (
|
||||
github.com/gookit/color v1.5.3
|
||||
github.com/joho/godotenv v1.5.1
|
||||
github.com/spf13/cobra v1.7.0
|
||||
)
|
||||
@ -10,4 +11,6 @@ require (
|
||||
require (
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
|
||||
golang.org/x/sys v0.6.0 // indirect
|
||||
)
|
||||
|
10
go.sum
10
go.sum
@ -1,12 +1,22 @@
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/gookit/color v1.5.3 h1:twfIhZs4QLCtimkP7MOxlF3A0U/5cDPseRT9M/+2SCE=
|
||||
github.com/gookit/color v1.5.3/go.mod h1:NUzwzeehUfl7GIb36pqId+UGmRfQcU/WiiyTTeNjHtE=
|
||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
|
||||
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
|
||||
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.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
||||
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8=
|
||||
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs=
|
||||
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
@ -1,9 +1,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"kode-starter/cmdCreate"
|
||||
"kode-starter/cmdEnv"
|
||||
"kode-starter/cmdLists"
|
||||
"kode-starter/config"
|
||||
"kode-starter/create"
|
||||
"kode-starter/lists"
|
||||
"kode-starter/utils"
|
||||
"kode-starter/version"
|
||||
|
||||
@ -21,8 +22,9 @@ var rootCmd = &cobra.Command{
|
||||
},
|
||||
}
|
||||
|
||||
var token, org, name, private, description string
|
||||
var token, org, name, private, description, group string
|
||||
var verbose, createFlag bool
|
||||
var listFlag, envVariablesFlag, groupFlag bool
|
||||
|
||||
func init() {
|
||||
|
||||
@ -30,18 +32,25 @@ func init() {
|
||||
|
||||
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "mode verbose")
|
||||
rootCmd.PersistentFlags().BoolVarP(&createFlag, "json", "j", false, "Print output as json format")
|
||||
// rootCmd.PersistentFlags().BoolVarP(&envVariablesFlag, "env", "e", false, "environment variables ")
|
||||
|
||||
lists.ListCmd.Flags().StringVarP(&token, "token", "t", "", "Github token")
|
||||
lists.ListCmd.Flags().StringVarP(&org, "org", "o", "", "Github organization")
|
||||
cmdLists.ListCmd.Flags().StringVarP(&token, "token", "t", "", "Github token")
|
||||
cmdLists.ListCmd.Flags().StringVarP(&org, "org", "o", "", "Github organization")
|
||||
|
||||
create.CreateCmd.Flags().StringVarP(&token, "token", "t", "", "Github token")
|
||||
create.CreateCmd.Flags().StringVarP(&org, "org", "o", "", "Github organization")
|
||||
create.CreateCmd.Flags().StringVarP(&name, "name", "n", "", "Project name")
|
||||
create.CreateCmd.Flags().StringVarP(&description, "desc", "d", "", "Description")
|
||||
create.CreateCmd.Flags().StringVarP(&private, "private", "p", "", "true/false")
|
||||
cmdCreate.CreateCmd.Flags().StringVarP(&token, "token", "t", "", "Github token")
|
||||
cmdCreate.CreateCmd.Flags().StringVarP(&org, "org", "o", "", "Github organization")
|
||||
cmdCreate.CreateCmd.Flags().StringVarP(&name, "name", "n", "", "Project name")
|
||||
cmdCreate.CreateCmd.Flags().StringVarP(&description, "desc", "d", "", "Description")
|
||||
cmdCreate.CreateCmd.Flags().StringVarP(&private, "private", "p", "", "true/false")
|
||||
|
||||
rootCmd.AddCommand(lists.ListCmd)
|
||||
rootCmd.AddCommand(create.CreateCmd)
|
||||
cmdEnv.EnvCmd.Flags().BoolVarP(&listFlag, "list", "l", false, "List options")
|
||||
cmdEnv.EnvCmd.Flags().BoolVarP(&envVariablesFlag, "env", "e", false, "environnement variables")
|
||||
cmdEnv.EnvCmd.Flags().BoolVarP(&groupFlag, "group", "g", false, "categories of informations")
|
||||
cmdEnv.EnvCmd.Flags().StringVarP(&group, "filter", "f", "", "filter for a specific category")
|
||||
|
||||
rootCmd.AddCommand(cmdLists.ListCmd)
|
||||
rootCmd.AddCommand(cmdCreate.CreateCmd)
|
||||
rootCmd.AddCommand(cmdEnv.EnvCmd)
|
||||
|
||||
}
|
||||
|
||||
@ -56,9 +65,11 @@ func mainProgram(cmd *cobra.Command, args []string) {
|
||||
utils.PrintHelpFormated(version.GetFullVersion(), config.GetAuthor(), config.GetBuildDate(), cmd)
|
||||
return
|
||||
} else {
|
||||
|
||||
// If no flag is set, show help
|
||||
utils.PrintHelpFormated(version.GetFullVersion(), config.GetAuthor(), config.GetBuildDate(), cmd)
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,18 +6,19 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/gookit/color"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func PrintHeader() {
|
||||
fmt.Println(CreateLine(15))
|
||||
fmt.Println(" __ __ __ ______ __ ")
|
||||
fmt.Println(" / //_/ ____ ____/ / ___ / ____/ _____ ___ ____ _ / /_ ____ _____")
|
||||
fmt.Println(" / ,< / __ \\ / __ / / _ \\ ______ / / / ___/ / _ \\ / __ `/ / __/ / __ \\ / ___/")
|
||||
fmt.Println(" / /| | / /_/ // /_/ / / __//_____// /___ / / / __// /_/ / / /_ / /_/ / / / ")
|
||||
fmt.Println("/_/ |_| \\____/ \\__,_/ \\___/ \\____/ /_/ \\___/ \\__,_/ \\__/ \\____/ /_/ ")
|
||||
fmt.Println("")
|
||||
fmt.Println(CreateLine(15))
|
||||
color.Yellow.Println(CreateLine(15))
|
||||
color.Green.Println(" __ __ __ ______ __ ")
|
||||
color.Green.Println(" / //_/ ____ ____/ / ___ / ____/ _____ ___ ____ _ / /_ ____ _____")
|
||||
color.Green.Println(" / ,< / __ \\ / __ / / _ \\ ______ / / / ___/ / _ \\ / __ `/ / __/ / __ \\ / ___/")
|
||||
color.Green.Println(" / /| | / /_/ // /_/ / / __//_____// /___ / / / __// /_/ / / /_ / /_/ / / / ")
|
||||
color.Green.Println("/_/ |_| \\____/ \\__,_/ \\___/ \\____/ /_/ \\___/ \\__,_/ \\__/ \\____/ /_/ ")
|
||||
color.Green.Println("")
|
||||
color.Yellow.Println(CreateLine(15))
|
||||
|
||||
}
|
||||
|
||||
@ -34,9 +35,9 @@ func PrintHelpFormated(version string, author string, buildDate string, cmd *cob
|
||||
fmt.Println("")
|
||||
cmd.Help()
|
||||
fmt.Println("")
|
||||
fmt.Println(CreateLine(15))
|
||||
fmt.Println("| Version: " + version + " || Author: " + author + " || Build date: " + buildDate + " |")
|
||||
fmt.Println(CreateLine(15))
|
||||
color.Yellow.Println(CreateLine(15))
|
||||
color.Green.Println("| Version: " + version + " || Author: " + author + " || Build date: " + buildDate + " |")
|
||||
color.Yellow.Println(CreateLine(15))
|
||||
fmt.Println("")
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user