parser

package
v1.0.0-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Command

func Command() *cobra.Command

func ID

func ID(s string) string

ID is a FlexStrTransformer that does not mutate the string.

Types

type FlexStr

type FlexStr string

A FlexStr describes an identifier of an Entity (Message, Field, Enum, Service, Field). It can be converted to multiple forms using the provided helper methods, or a custom transform can be used to modify its behavior.

func (FlexStr) LowerCamelCase

func (n FlexStr) LowerCamelCase() FlexStr

LowerCamelCase converts FlexStr n to lower camelcase, where each part is title-cased and concatenated with no separator except the first which is lower-cased.

func (FlexStr) LowerDashNotation

func (n FlexStr) LowerDashNotation() FlexStr

LowerDashNotation converts FlexStr n to lower-dash-notation, where each part is lower-cased and concatenated with dash.

func (FlexStr) LowerDotNotation

func (n FlexStr) LowerDotNotation() FlexStr

LowerDotNotation converts FlexStr n to lower dot notation, where each part is lower-cased and concatenated with periods.

func (FlexStr) LowerSnakeCase

func (n FlexStr) LowerSnakeCase() FlexStr

LowerSnakeCase converts FlexStr n to lower-snake-case, where each part is lower-cased and concatenated with underscores.

func (FlexStr) ScreamingSnakeCase

func (n FlexStr) ScreamingSnakeCase() FlexStr

ScreamingSnakeCase converts FlexStr n to screaming-snake-case, where each part is all-caps and concatenated with underscores.

func (FlexStr) SnakeCase

func (n FlexStr) SnakeCase() FlexStr

SnakeCase converts FlexStr n to snake-case, where each part preserves its capitalization and concatenated with underscores.

func (FlexStr) Split

func (n FlexStr) Split() (parts []string)

Split breaks apart FlexStr n into its constituent components. Precedence follows dot notation, then underscores (excluding underscore prefixes), then camelcase. Numbers are treated as standalone components.

func (FlexStr) String

func (n FlexStr) String() string

String satisfies the strings.Stringer interface.

func (FlexStr) Transform

func (n FlexStr) Transform(mod, first FlexStrTransformer, sep string) FlexStr

Transform applies a transformation to the parts of FlexStr n, returning a new FlexStr. Transformer first is applied to the first part, with mod applied to all subsequent ones. The parts are then concatenated with the separator sep. For optimal efficiency, multiple FlexStrTransformers should be Chained together before calling Transform.

func (FlexStr) UpperCamelCase

func (n FlexStr) UpperCamelCase() FlexStr

UpperCamelCase converts FlexStr n to upper camelcase, where each part is title-cased and concatenated with no separator.

func (FlexStr) UpperDotNotation

func (n FlexStr) UpperDotNotation() FlexStr

UpperDotNotation converts FlexStr n to upper dot notation, where each part is title-cased and concatenated with periods.

func (FlexStr) UpperSnakeCase

func (n FlexStr) UpperSnakeCase() FlexStr

UpperSnakeCase converts FlexStr n to upper-snake-case, where each part is title-cased and concatenated with underscores.

type FlexStrTransformer

type FlexStrTransformer func(string) string

FlexStrTransformer is a function that mutates a string. Many of the methods in the standard strings package satisfy this signature.

func (FlexStrTransformer) Chain

Chain combines the behavior of two Transformers into one. If multiple transformations need to be performed on a FlexStr, this method should be used to reduce it to a single transformation before applying.

type Opt

type Opt func(c *config)

func WithFS

func WithFS(fs fs.FS) Opt

func WithOverride

func WithOverride(override bool) Opt

func WithParams

func WithParams(params map[string]interface{}) Opt

func WithWatermark

func WithWatermark(watermark string) Opt

type Parser

type Parser interface {
	WithOption(opt ...Opt) Parser
	Parse(source, destination string) error
}

func New

func New(opts ...Opt) Parser

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL