transform

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BuiltinTransformers = map[string]Transformer{
	"lowercase":      Lowercase,
	"uppercase":      Uppercase,
	"capitalize":     Capitalize,
	"title":          TitleCase,
	"trim":           Trim,
	"no-punctuation": RemovePunctuation,
	"no-whitespace":  RemoveWhitespace,
}

Functions

func ApplyResults

func ApplyResults(ctx context.Context, client Applier, results []Result)

func ApplyResultsWithOptions

func ApplyResultsWithOptions(ctx context.Context, client Applier, results []Result, asChild bool)

func ApplySplitResults

func ApplySplitResults(ctx context.Context, client Applier, results []SplitResult)

func BuildUpdateRequest

func BuildUpdateRequest(result *Result) *workflowy.UpdateNodeRequest

func Capitalize

func Capitalize(s string) (string, error)

func CollectSplits

func CollectSplits(items []*workflowy.Item, separator string, field Field, skipEmpty bool, depth int, maxDepth int, results *[]SplitResult)

func CollectTransformations

func CollectTransformations(items []*workflowy.Item, opts Options, depth int, results *[]Result)

func ListBuiltins

func ListBuiltins() []string

func Lowercase

func Lowercase(s string) (string, error)

func RemovePunctuation

func RemovePunctuation(s string) (string, error)

func RemoveWhitespace

func RemoveWhitespace(s string) (string, error)

func Split

func Split(text, separator string, skipEmpty bool) []string

func TitleCase

func TitleCase(s string) (string, error)

func Trim

func Trim(s string) (string, error)

func UnescapeSeparator

func UnescapeSeparator(s string) string

func Uppercase

func Uppercase(s string) (string, error)

Types

type Applier

type Applier interface {
	UpdateNode(ctx context.Context, itemID string, req *workflowy.UpdateNodeRequest) (*workflowy.UpdateNodeResponse, error)
	CreateNode(ctx context.Context, req *workflowy.CreateNodeRequest) (*workflowy.CreateNodeResponse, error)
}

type Field

type Field int
const (
	FieldName Field = 1 << iota
	FieldNote
)

func DetermineFields

func DetermineFields(name, note bool) Field

type Options

type Options struct {
	Transformer Transformer
	Fields      Field
	DryRun      bool
	Interactive bool
	Depth       int
	AsChild     bool
}

type Result

type Result struct {
	Item       *workflowy.Item `json:"-"`
	ID         string          `json:"id"`
	URL        string          `json:"url"`
	Field      string          `json:"field"`
	Original   string          `json:"original"`
	New        string          `json:"new"`
	Applied    bool            `json:"applied"`
	Skipped    bool            `json:"skipped,omitempty"`
	SkipReason string          `json:"skip_reason,omitempty"`
	Error      error           `json:"error,omitempty"`
	CreatedID  string          `json:"created_id,omitempty"`
}

func (Result) String

func (r Result) String() string

type SplitResult

type SplitResult struct {
	ParentID   string   `json:"parent_id"`
	ParentURL  string   `json:"parent_url"`
	Original   string   `json:"original"`
	Parts      []string `json:"parts"`
	CreatedIDs []string `json:"created_ids,omitempty"`
	Applied    bool     `json:"applied"`
	Skipped    bool     `json:"skipped,omitempty"`
	SkipReason string   `json:"skip_reason,omitempty"`
}

func (SplitResult) String

func (r SplitResult) String() string

type Transformer

type Transformer func(string) (string, error)

func ResolveTransformer

func ResolveTransformer(transformName, execCmd string) (Transformer, error)

func ShellTransformer

func ShellTransformer(cmdTemplate string) Transformer

Jump to

Keyboard shortcuts

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