Skip to content

Commit 2295b20

Browse files
author
Ish Shah
committed
init structure
1 parent 347aaa1 commit 2295b20

File tree

3 files changed

+48
-8
lines changed

3 files changed

+48
-8
lines changed

cmd/operator-sdk/main.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ import (
4444
)
4545

4646
func main() {
47+
root := GetCLIRoot()
48+
49+
root.PersistentFlags().Bool(flags.VerboseOpt, false, "Enable verbose logging")
50+
if err := viper.BindPFlags(root.PersistentFlags()); err != nil {
51+
log.Fatalf("Failed to bind root flags: %v", err)
52+
}
53+
54+
if err := root.Execute(); err != nil {
55+
os.Exit(1)
56+
}
57+
}
58+
59+
// GetCLIRoot is intended to creeate the base command structure for the OSDK for use in CLI and documentation
60+
func GetCLIRoot() *cobra.Command {
4761
root := &cobra.Command{
4862
Use: "operator-sdk",
4963
Short: "An SDK for building operators with ease",
@@ -76,14 +90,7 @@ func main() {
7690
root.AddCommand(up.NewCmd())
7791
root.AddCommand(version.NewCmd())
7892

79-
root.PersistentFlags().Bool(flags.VerboseOpt, false, "Enable verbose logging")
80-
if err := viper.BindPFlags(root.PersistentFlags()); err != nil {
81-
log.Fatalf("Failed to bind root flags: %v", err)
82-
}
83-
84-
if err := root.Execute(); err != nil {
85-
os.Exit(1)
86-
}
93+
return root
8794
}
8895

8996
func checkGoModulesForCmd(cmd *cobra.Command) (err error) {

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ require (
2424
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect
2525
github.com/fatih/camelcase v1.0.0 // indirect
2626
github.com/ghodss/yaml v1.0.0
27+
github.com/go-logfmt/logfmt v0.4.0 // indirect
2728
github.com/go-logr/logr v0.1.0
2829
github.com/go-logr/zapr v0.1.1
2930
github.com/go-openapi/swag v0.19.0 // indirect

hack/doc/gen-cli-doc.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2019 The Operator-SDK Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package main
16+
17+
import (
18+
cmd "github.com/operator-framework/operator-sdk/cmd/operator-sdk"
19+
20+
"github.com/spf13/cobra/doc"
21+
22+
log "github.com/sirupsen/logrus"
23+
)
24+
25+
func main() {
26+
root := cmd.GetCLIRoot()
27+
28+
err := doc.GenMarkdownTree(root, "../../doc")
29+
if err != nil {
30+
log.Fatalf("Failed to generate documenation, (%v)", err)
31+
}
32+
}

0 commit comments

Comments
 (0)