Documentation
¶
Index ¶
- Variables
- func ApplyGroupResults(ctx context.Context, client GroupApplier, results []GroupResult, ...) error
- func ApplyResults(ctx context.Context, client Applier, results []Result)
- func ApplyResultsWithOptions(ctx context.Context, client Applier, results []Result, asChild bool)
- func ApplySplitResults(ctx context.Context, client Applier, results []SplitResult)
- func BuildUpdateRequest(result *Result) *workflowy.UpdateNodeRequest
- func Capitalize(s string) (string, error)
- func CollectSplits(items []*workflowy.Item, separator string, field Field, skipEmpty bool, ...)
- func CollectSplitsRegex(items []*workflowy.Item, pattern *regexp.Regexp, field Field, skipEmpty bool, ...)
- func CollectTransformations(items []*workflowy.Item, opts Options, depth int, results *[]Result)
- func DateKeyFromTimeTag(name, granularity string) (string, bool)
- func ExtractDateFromTimeTag(name string) (year, month, day int, found bool)
- func GenerateTimeTag(t time.Time, granularity string) string
- func ListBuiltins() []string
- func Lowercase(s string) (string, error)
- func ParseGroupBy(value string) (field, format, granularity string, err error)
- func ParseOrder(value, field string) (ascending bool, err error)
- func RemovePunctuation(s string) (string, error)
- func RemoveWhitespace(s string) (string, error)
- func Split(text, separator string, skipEmpty bool) []string
- func SplitRegex(text string, pattern *regexp.Regexp, skipEmpty bool) []string
- func TitleCase(s string) (string, error)
- func Trim(s string) (string, error)
- func UnescapeSeparator(s string) string
- func Uppercase(s string) (string, error)
- type Applier
- type DateGroup
- type Field
- type GroupApplier
- type GroupOptions
- type GroupResult
- type GroupedItem
- type Options
- type Result
- type SplitResult
- type Transformer
Constants ¶
This section is empty.
Variables ¶
var BuiltinTransformers = map[string]Transformer{ "lowercase": Lowercase, "uppercase": Uppercase, "capitalize": Capitalize, "title": TitleCase, "trim": Trim, "no-punctuation": RemovePunctuation, "no-whitespace": RemoveWhitespace, }
var MarkdownListPattern = regexp.MustCompile(`\s*(?:[-*+]|\d+[.)])\s+`)
MarkdownListPattern matches markdown list markers: - Unordered: -, *, + - Ordered: 1., 2., 1), 2), etc. The pattern splits on the marker, leaving the content after each marker.
var TimeTagPattern = regexp.MustCompile(`<time\s+startYear="(\d+)"(?:\s+startMonth="(\d+)")?(?:\s+startDay="(\d+)")?[^>]*>[^<]*</time>`)
TimeTagPattern matches Workflowy time tags.
Functions ¶
func ApplyGroupResults ¶ added in v0.8.1
func ApplyGroupResults(ctx context.Context, client GroupApplier, results []GroupResult, granularity string) error
ApplyGroupResults applies the grouping by creating headers and moving items.
func ApplyResultsWithOptions ¶
func ApplySplitResults ¶
func ApplySplitResults(ctx context.Context, client Applier, results []SplitResult)
func BuildUpdateRequest ¶
func BuildUpdateRequest(result *Result) *workflowy.UpdateNodeRequest
func Capitalize ¶
func CollectSplits ¶
func CollectSplitsRegex ¶ added in v0.8.1
func CollectTransformations ¶
func DateKeyFromTimeTag ¶ added in v0.8.1
DateKeyFromTimeTag extracts a date key from a time tag based on granularity.
func ExtractDateFromTimeTag ¶ added in v0.8.1
ExtractDateFromTimeTag extracts year, month, day from a time tag.
func GenerateTimeTag ¶ added in v0.8.1
GenerateTimeTag creates a Workflowy time tag for a given date and granularity.
func ListBuiltins ¶
func ListBuiltins() []string
func ParseGroupBy ¶ added in v0.8.1
ParseGroupBy parses a --by value into GroupOptions fields.
func ParseOrder ¶ added in v0.8.1
ParseOrder parses a --order value.
func RemovePunctuation ¶
func RemoveWhitespace ¶
func SplitRegex ¶ added in v0.8.1
func UnescapeSeparator ¶
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 DateGroup ¶ added in v0.8.1
type DateGroup struct {
DateKey string `json:"date_key"`
TimeTag string `json:"time_tag"`
HeaderID string `json:"header_id,omitempty"`
ExistingHeader bool `json:"existing_header"`
Items []GroupedItem `json:"items"`
CreatedID string `json:"created_id,omitempty"`
}
DateGroup represents a group of items under a date header.
type GroupApplier ¶ added in v0.8.1
type GroupApplier interface {
Applier
MoveNode(ctx context.Context, itemID string, req *workflowy.MoveNodeRequest) (*workflowy.MoveNodeResponse, error)
}
GroupApplier extends Applier with MoveNode for group operations.
type GroupOptions ¶ added in v0.8.1
type GroupOptions struct {
Field string // "created" or "modified"
Format string // Go time format string for grouping
Granularity string // "year", "month", "day", or custom
Ascending bool // Sort order (false = newest first)
DryRun bool
}
GroupOptions configures the group transform.
type GroupResult ¶ added in v0.8.1
type GroupResult struct {
ParentID string `json:"parent_id"`
ParentURL string `json:"parent_url"`
Groups []DateGroup `json:"groups"`
Applied bool `json:"applied"`
NoDateItems []GroupedItem `json:"no_date_items,omitempty"`
}
GroupResult represents the result of grouping children.
func CollectGroupResults ¶ added in v0.8.1
func CollectGroupResults(items []*workflowy.Item, opts GroupOptions) []GroupResult
CollectGroupResults groups children of the given items by date.
func (GroupResult) String ¶ added in v0.8.1
func (r GroupResult) String() string
type GroupedItem ¶ added in v0.8.1
type GroupedItem struct {
ID string `json:"id"`
Name string `json:"name"`
URL string `json:"url"`
Timestamp int64 `json:"timestamp"`
DateKey string `json:"date_key"`
}
GroupedItem represents an item that will be grouped.
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"`
}
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 ¶
func ResolveTransformer ¶
func ResolveTransformer(transformName, execCmd string) (Transformer, error)
func ShellTransformer ¶
func ShellTransformer(cmdTemplate string) Transformer