Commit c87cd9c0 authored by juanvallejo's avatar juanvallejo

sort on non-tabular output

parent 0ef96cba
...@@ -241,6 +241,8 @@ func (o *GetOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []stri ...@@ -241,6 +241,8 @@ func (o *GetOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []stri
if err != nil { if err != nil {
return nil, err return nil, err
} }
printer = maybeWrapSortingPrinter(printer, isSorting)
return printer.PrintObj, nil return printer.PrintObj, nil
} }
...@@ -738,3 +740,13 @@ func shouldGetNewPrinterForMapping(printer printers.ResourcePrinter, lastMapping ...@@ -738,3 +740,13 @@ func shouldGetNewPrinterForMapping(printer printers.ResourcePrinter, lastMapping
func cmdSpecifiesOutputFmt(cmd *cobra.Command) bool { func cmdSpecifiesOutputFmt(cmd *cobra.Command) bool {
return cmdutil.GetFlagString(cmd, "output") != "" return cmdutil.GetFlagString(cmd, "output") != ""
} }
func maybeWrapSortingPrinter(printer printers.ResourcePrinter, sortBy string) printers.ResourcePrinter {
if len(sortBy) != 0 {
return &kubectl.SortingPrinter{
Delegate: printer,
SortField: fmt.Sprintf("%s", sortBy),
}
}
return printer
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment