Skip to content

Commit

Permalink
kudo get cmd help (#1674)
Browse files Browse the repository at this point in the history
Signed-off-by: Ken Sipe <kensipe@gmail.com>
  • Loading branch information
kensipe committed Sep 4, 2020
1 parent ede03e8 commit 8c30604
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pkg/kudoctl/clog/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (l *Level) Set(value string) error {

// Type is part of flag.Value interface
func (l *Level) Type() string {
return string(*l)
return fmt.Sprint(*l)
}

//// pflag.Value interface ends
Expand Down
20 changes: 16 additions & 4 deletions pkg/kudoctl/cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,19 @@ import (
)

const getExample = ` # Get all available instances
kubectl kudo get instances
kubectl kudo get instances
# Get all available operators
kubectl kudo get operators
# Get all available operatorversions
kubectl kudo get operatorversions
# Get all installed components
kubectl kudo get all
# Get all installed components as yaml
kubectl kudo get all -o yaml
`

// newGetCmd creates a command that lists the instances in the cluster
Expand All @@ -20,8 +32,8 @@ func newGetCmd(out io.Writer) *cobra.Command {
}

getCmd := &cobra.Command{
Use: "get instances",
Short: "Gets all available instances.",
Use: "get <instances|operators|operatorversions|all> [flags]",
Short: "Gets list of installed components (instances, operators, operatorversions or all).",
Example: getExample,
RunE: func(cmd *cobra.Command, args []string) error {
client, err := env.GetClient(&Settings)
Expand All @@ -35,7 +47,7 @@ func newGetCmd(out io.Writer) *cobra.Command {
},
}

getCmd.Flags().StringVarP(opts.Output.AsStringPtr(), "output", "o", "", "Output format for command results.")
getCmd.Flags().StringVarP(opts.Output.AsStringPtr(), "output", "o", "", "Output format. One of: json|yaml")

return getCmd
}
12 changes: 6 additions & 6 deletions pkg/kudoctl/cmd/get/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func Run(args []string, opts CmdOpts) error {
}

if opts.Output.IsFormattedOutput() {
outObj := []interface{}{}
var outObj []interface{}
for _, o := range objs {
outObj = append(outObj, o)
}
Expand All @@ -74,8 +74,8 @@ func Run(args []string, opts CmdOpts) error {
}
tree.AddBranch(name)
}
_, _ = fmt.Fprintf(opts.Out, "List of current installed %s in namespace %q:\n", args[0], opts.Namespace)
_, _ = fmt.Fprintln(opts.Out, tree.String())
fmt.Fprintf(opts.Out, "List of current installed %s in namespace %q:\n", args[0], opts.Namespace)
fmt.Fprintln(opts.Out, tree.String())
return err
}

Expand All @@ -94,7 +94,7 @@ func runGetAll(opts CmdOpts) error {
}

if opts.Output.IsFormattedOutput() {
outObj := []interface{}{}
var outObj []interface{}
for _, o := range operators {
outObj = append(outObj, o)
}
Expand Down Expand Up @@ -132,8 +132,8 @@ func printAllTree(opts CmdOpts, operators, operatorversions, instances []runtime
}
}

_, _ = fmt.Fprintf(opts.Out, "List of current installed operators including versions and instances in namespace %q:\n", opts.Namespace)
_, _ = fmt.Fprintln(opts.Out, rootTree.String())
fmt.Fprintf(opts.Out, "List of current installed operators including versions and instances in namespace %q:\n", opts.Namespace)
fmt.Fprintln(opts.Out, rootTree.String())
return nil

}
Expand Down

0 comments on commit 8c30604

Please sign in to comment.