transform

package
v1.70.3 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package transform holds functions for path name transformations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppyTimeGlobs

func AppyTimeGlobs(s string, t time.Time) string

AppyTimeGlobs converts "myfile-{DateOnly}.txt" to "myfile-2006-01-02.txt"

func Help added in v1.70.1

func Help() string

Help returns the help string cleaned up to simplify appending

func ParseGlobs

func ParseGlobs(s string) (hasGlobs bool, substring string)

ParseGlobs determines whether a string contains {brackets} and returns the substring (including both brackets) for replacing substring is first opening bracket to last closing bracket -- good for {{this}} but not {this}{this}

func Path

func Path(ctx context.Context, s string, isDir bool) string

Path transforms a path s according to the --name-transform options in use

If no transforms are in use, s is returned unchanged

func SetOptions

func SetOptions(ctx context.Context, s ...string) (err error)

SetOptions sets the options in ctx from flags passed in. Any existing flags will be overwritten. s should be in the same format as cmd line flags, i.e. "all,prefix=XXX"

func SuffixKeepExtension

func SuffixKeepExtension(remote string, suffix string) string

SuffixKeepExtension adds a suffix while keeping extension

i.e. file.txt becomes file_somesuffix.txt not file.txt_somesuffix

func TimeFormat

func TimeFormat(timeFormat string) string

TimeFormat converts a user-supplied string to a Go time constant, if possible

func Transforming

func Transforming(ctx context.Context) bool

Transforming returns true when transforms are in use

func TrimBrackets

func TrimBrackets(s string) string

TrimBrackets converts {{this}} to this

Types

type Algo added in v1.70.1

type Algo = fs.Enum[transformChoices]

Algo describes conversion setting

const (
	ConvNone Algo = iota
	ConvToNFC
	ConvToNFD
	ConvToNFKC
	ConvToNFKD
	ConvFindReplace
	ConvPrefix
	ConvSuffix
	ConvSuffixKeepExtension
	ConvTrimPrefix
	ConvTrimSuffix
	ConvIndex
	ConvDate
	ConvTruncate
	ConvBase64Encode
	ConvBase64Decode
	ConvEncoder
	ConvDecoder
	ConvISO8859_1
	ConvWindows1252
	ConvMacintosh
	ConvCharmap
	ConvLowercase
	ConvUppercase
	ConvTitlecase
	ConvASCII
	ConvURL
	ConvRegex
	ConvCommand
)

Supported transform options

type CharmapChoices added in v1.70.1

type CharmapChoices = fs.Enum[cmapChoices]

CharmapChoices is an enum of the character map choices.

Jump to

Keyboard shortcuts

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