github.com/tomwright/dasel@v1.27.3/storage/option.go (about)

     1  package storage
     2  
     3  // IndentOption returns a write option that sets the given indent.
     4  func IndentOption(indent string) ReadWriteOption {
     5  	return ReadWriteOption{
     6  		Key:   OptionIndent,
     7  		Value: indent,
     8  	}
     9  }
    10  
    11  // PrettyPrintOption returns an option that enables or disables pretty printing.
    12  func PrettyPrintOption(enabled bool) ReadWriteOption {
    13  	return ReadWriteOption{
    14  		Key:   OptionPrettyPrint,
    15  		Value: enabled,
    16  	}
    17  }
    18  
    19  // ColouriseOption returns an option that enables or disables colourised output.
    20  func ColouriseOption(enabled bool) ReadWriteOption {
    21  	return ReadWriteOption{
    22  		Key:   OptionColourise,
    23  		Value: enabled,
    24  	}
    25  }
    26  
    27  // EscapeHTMLOption returns an option that enables or disables HTML escaping.
    28  func EscapeHTMLOption(enabled bool) ReadWriteOption {
    29  	return ReadWriteOption{
    30  		Key:   OptionEscapeHTML,
    31  		Value: enabled,
    32  	}
    33  }
    34  
    35  // OptionKey is a defined type for keys within a ReadWriteOption.
    36  type OptionKey string
    37  
    38  const (
    39  	// OptionIndent is the key used with IndentOption.
    40  	OptionIndent OptionKey = "indent"
    41  	// OptionPrettyPrint is the key used with PrettyPrintOption.
    42  	OptionPrettyPrint OptionKey = "prettyPrint"
    43  	// OptionColourise is the key used with ColouriseOption.
    44  	OptionColourise OptionKey = "colourise"
    45  	// OptionEscapeHTML is the key used with EscapeHTMLOption.
    46  	OptionEscapeHTML OptionKey = "escapeHtml"
    47  )
    48  
    49  // ReadWriteOption is an option to be used when writing.
    50  type ReadWriteOption struct {
    51  	Key   OptionKey
    52  	Value interface{}
    53  }