@@ -30,15 +30,11 @@ import (
30
30
// rootCmd represents the base command when called without any subcommands
31
31
var rootCmd = & cobra.Command {
32
32
Use : "kepctl" ,
33
- Short : "kepctl helps you build keps " ,
33
+ Short : "kepctl helps you build KEPs " ,
34
34
PersistentPreRunE : initLogging ,
35
35
}
36
36
37
- type rootOptions struct {
38
- logLevel string
39
- }
40
-
41
- var rootOpts = & rootOptions {}
37
+ var rootOpts = & kepctl.CommonArgs {}
42
38
43
39
// Execute adds all child commands to the root command and sets flags appropriately.
44
40
// This is called by main.main(). It only needs to happen once to the rootCmd.
@@ -50,45 +46,28 @@ func Execute() {
50
46
51
47
func init () {
52
48
rootCmd .PersistentFlags ().StringVar (
53
- & rootOpts .logLevel ,
49
+ & rootOpts .LogLevel ,
54
50
"log-level" ,
55
51
"info" ,
56
52
fmt .Sprintf ("the logging verbosity, either %s" , log .LevelNames ()),
57
53
)
58
- }
59
54
60
- func initLogging (* cobra.Command , []string ) error {
61
- return log .SetupGlobalLogger (rootOpts .logLevel )
62
- }
63
-
64
- // TODO: Refactor/remove below
55
+ // TODO: This should be defaulted in the package instead
56
+ rootCmd .PersistentFlags ().StringVar (
57
+ & rootOpts .RepoPath ,
58
+ "repo-path" ,
59
+ os .Getenv ("ENHANCEMENTS_PATH" ),
60
+ "path to kubernetes/enhancements" ,
61
+ )
65
62
66
- func main () {
67
- cmd , err := buildMainCommand ()
68
- if err != nil {
69
- fmt .Fprintln (os .Stderr , err )
70
- os .Exit (1 )
71
- }
72
- if err := cmd .Execute (); err != nil {
73
- fmt .Fprintln (os .Stderr , err )
74
- os .Exit (1 )
75
- }
63
+ rootCmd .PersistentFlags ().StringVar (
64
+ & rootOpts .TokenPath ,
65
+ "gh-token-path" ,
66
+ "" ,
67
+ "path to a file with a GitHub API token" ,
68
+ )
76
69
}
77
70
78
- func buildMainCommand () (* cobra.Command , error ) {
79
- repoPath := os .Getenv ("ENHANCEMENTS_PATH" )
80
- k , err := kepctl .New (repoPath )
81
- if err != nil {
82
- return nil , err
83
- }
84
-
85
- rootCmd := & cobra.Command {
86
- Use : "kepctl" ,
87
- Short : "kepctl helps you build keps" ,
88
- }
89
-
90
- rootCmd .AddCommand (buildCreateCommand (k ))
91
- rootCmd .AddCommand (buildPromoteCommand (k ))
92
- rootCmd .AddCommand (buildQueryCommand (k ))
93
- return rootCmd , nil
71
+ func initLogging (* cobra.Command , []string ) error {
72
+ return log .SetupGlobalLogger (rootOpts .LogLevel )
94
73
}
0 commit comments