Skip to content

Commit 277d92c

Browse files
committed
cobra init
1 parent 48d513f commit 277d92c

File tree

4 files changed

+67
-0
lines changed

4 files changed

+67
-0
lines changed

cmd/root.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package cmd
2+
3+
import (
4+
"os"
5+
6+
"github.com/spf13/cobra"
7+
)
8+
9+
// rootCmd represents the base command when called without any subcommands
10+
var rootCmd = &cobra.Command{
11+
Use: "bootstrapper",
12+
Short: "A brief description of your application",
13+
Long: `A longer description that spans multiple lines and likely contains
14+
examples and usage of using your application. For example:
15+
16+
Cobra is a CLI library for Go that empowers applications.
17+
This application is a tool to generate the needed files
18+
to quickly create a Cobra application.`,
19+
// Uncomment the following line if your bare application
20+
// has an action associated with it:
21+
// Run: func(cmd *cobra.Command, args []string) { },
22+
}
23+
24+
// Execute adds all child commands to the root command and sets flags appropriately.
25+
// This is called by main.main(). It only needs to happen once to the rootCmd.
26+
func Execute() {
27+
err := rootCmd.Execute()
28+
if err != nil {
29+
os.Exit(1)
30+
}
31+
}
32+
33+
func init() {
34+
// Here you will define your flags and configuration settings.
35+
// Cobra supports persistent flags, which, if defined here,
36+
// will be global for your application.
37+
38+
// rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.bootstrapper.yaml)")
39+
40+
// Cobra also supports local flags, which will only run
41+
// when this action is called directly.
42+
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
43+
}

go.mod

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
module github.com/openmcp-project/bootstrapper
22

33
go 1.24.5
4+
5+
require (
6+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
7+
github.com/spf13/cobra v1.9.1 // indirect
8+
github.com/spf13/pflag v1.0.7 // indirect
9+
)

go.sum

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
2+
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
3+
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
4+
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
5+
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
6+
github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0=
7+
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
8+
github.com/spf13/pflag v1.0.7 h1:vN6T9TfwStFPFM5XzjsvmzZkLuaLX+HS+0SeFLRgU6M=
9+
github.com/spf13/pflag v1.0.7/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
10+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
11+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package main
2+
3+
import "github.com/openmcp-project/bootstrapper/cmd"
4+
5+
func main() {
6+
cmd.Execute()
7+
}

0 commit comments

Comments
 (0)