update PrintFlags#Complete to receive string template

This commit is contained in:
juanvallejo
2018-04-06 11:36:52 -04:00
parent b8dc20646c
commit 2a202cf49a
14 changed files with 54 additions and 64 deletions

View File

@@ -215,13 +215,17 @@ func (o *EnvOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []stri
o.Resources = resources
o.Cmd = cmd
o.PrintFlags.Complete(o.DryRun)
if o.DryRun {
// TODO(juanvallejo): This can be cleaned up even further by creating
// a PrintFlags struct that binds the --dry-run flag, and whose
// ToPrinter method returns a printer that understands how to print
// this success message.
o.PrintFlags.Complete("%s (dry run)")
}
printer, err := o.PrintFlags.ToPrinter()
if err != nil {
return err
}
o.PrintObj = func(obj runtime.Object) error {
return printer.PrintObj(obj, o.Out)
}