code: func resolveExporterDest(exporter, dest string) (io.WriteCloser, string, error) {
  	switch exporter {
  	case client.ExporterLocal:
  		if dest == "" {
  			return nil, "", errors.New("output directory is required for local exporter")
  		}
  		return nil, dest, nil
  	case client.ExporterOCI, client.ExporterDocker, client.ExporterTar:
  		if dest != "" && dest != "-" {
  			fi, err := os.Stat(dest)
  			if err != nil && !os.IsNotExist(err) {
  				return nil, "", errors.Wrapf(err, "invalid destination file: %s", dest)
  			}
  			if err == nil && fi.IsDir() {
  				return nil, "", errors.Errorf("destination file is a directory")
  			}
  			w, err := os.Create(dest)
  			return w, "", err
  		}
  		// if no output file is specified, use stdout
  		if _, err := console.ConsoleFromFile(os.Stdout); err == nil {
  			return nil, "", errors.Errorf("output file is required for %s exporter. refusing to write to console", exporter)
  		}
  		return os.Stdout, "", nil
  	default: // e.g. client.ExporterImage
  		if dest != "" {
  			return nil, "", errors.Errorf("output %s is not supported by %s exporter", dest, exporter)
  		}
  		return nil, "", nil
  	}
  }
docs: // resolveExporterDest returns at most either one of io.WriteCloser (single file) or a string (directory path).