Skip to content

Commit

Permalink
feat(cmd/example): Create exaple commad (as boilerplate for new comma…
Browse files Browse the repository at this point in the history
…nds)
  • Loading branch information
ondrejsika committed May 24, 2024
1 parent f9d7c2b commit 0b56a2f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import (
_ "github.com/sikalabs/slu/cmd/eck/elastic_password"
_ "github.com/sikalabs/slu/cmd/elasticsearch"
_ "github.com/sikalabs/slu/cmd/elasticsearch/get"
_ "github.com/sikalabs/slu/cmd/example"
_ "github.com/sikalabs/slu/cmd/example_server"
_ "github.com/sikalabs/slu/cmd/expand"
_ "github.com/sikalabs/slu/cmd/expand/file"
Expand Down Expand Up @@ -202,7 +203,6 @@ import (
_ "github.com/sikalabs/slu/cmd/scripts/kubernetes/install_hello_world"
_ "github.com/sikalabs/slu/cmd/scripts/kubernetes/install_ingress"
_ "github.com/sikalabs/slu/cmd/scripts/kubernetes/install_ingress_aks"
_ "github.com/sikalabs/slu/cmd/scripts/kubernetes/create_kubernetes_api_ingress"
_ "github.com/sikalabs/slu/cmd/scripts/kubernetes/install_maildev"
_ "github.com/sikalabs/slu/cmd/scripts/kubernetes/install_metrics_server"
_ "github.com/sikalabs/slu/cmd/scripts/kubernetes/install_prometheus_operator_crd"
Expand Down
28 changes: 28 additions & 0 deletions cmd/example/example.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package example

import (
"fmt"

"github.com/sikalabs/slu/cmd/root"
"github.com/spf13/cobra"
)

var FlagName string

func init() {
root.RootCmd.AddCommand(Cmd)
Cmd.Flags().StringVarP(&FlagName, "name", "n", "World", "Name to greet")
}

var Cmd = &cobra.Command{
Use: "example",
Short: "This is an example command, you can cerate your own command from this",
Args: cobra.NoArgs,
Run: func(c *cobra.Command, args []string) {
example(FlagName)
},
}

func example(name string) {
fmt.Printf("Hello, %s!\n", name)
}

0 comments on commit 0b56a2f

Please sign in to comment.