github.com/weaviate/weaviate@v1.24.6/entities/verbosity/verbosity.go (about)

     1  //                           _       _
     2  // __      _____  __ ___   ___  __ _| |_ ___
     3  // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
     4  //  \ V  V /  __/ (_| |\ V /| | (_| | ||  __/
     5  //   \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
     6  //
     7  //  Copyright © 2016 - 2024 Weaviate B.V. All rights reserved.
     8  //
     9  //  CONTACT: hello@weaviate.io
    10  //
    11  
    12  package verbosity
    13  
    14  import "fmt"
    15  
    16  const (
    17  	OutputMinimal = "minimal"
    18  	OutputVerbose = "verbose"
    19  )
    20  
    21  // ParseOutput extracts the verbosity value from the provided nullable string
    22  // If `output` is nil, the default selection is "minimal"
    23  func ParseOutput(output *string) (string, error) {
    24  	if output != nil {
    25  		switch *output {
    26  		case OutputMinimal, OutputVerbose:
    27  			return *output, nil
    28  		default:
    29  			return "", fmt.Errorf(`invalid output: "%s", possible values are: "%s", "%s"`,
    30  				*output, OutputMinimal, OutputVerbose)
    31  		}
    32  	}
    33  	return OutputMinimal, nil
    34  }