tag

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package tag provides a representation for short, descriptive words or phrases, used to describe the contents of a file.

The combination of multiple tags can help to uniquely classify files.

TIX's primary goal is management of duplicate files, including the alignment of their tags.

Since file tagging is a manual, almost random task, it is highly unlikely that all duplicates of a file will have the same set of tags. Some tags can be expected to be common to all duplicates, others may represent aspects of the file which were not considered while tagging the other duplicates.

There is also the consideration of inconsistent spelling, capitalisation or colorisation of tags.

This package provides:

  • basic tag attributes: text and color

  • merging the tags of multiple, identical files into a single tag set

  • while maintaining a (hopefully) recognisable order

  • identification and alignment of inconsitently spellt tags

  • the permanent replacement of tags

  • e.g. always replace 'important' with 'prio 1'

Index

Constants

View Source
const NoColor = "none"

Variables

This section is empty.

Functions

func ValidColorName added in v0.0.10

func ValidColorName(color string) string

Types

type List

type List []*Tag

List represents the ordered list of tags for a single file

func NewTagList

func NewTagList() List

NewTagList only provides a common New... interface to a simple list of tags

func (List) IsEqual

func (this List) IsEqual(other List) bool

func (List) Strings

func (tl List) Strings() []string

Strings returns the list of tags as strings... only required to get around go's limited type casting

type Preferences

type Preferences struct {
	// contains filtered or unexported fields
}

func NewPreferences

func NewPreferences() *Preferences

func (*Preferences) NewTag

func (p *Preferences) NewTag(name, color string) *Tag

type Set

type Set struct {
	// contains filtered or unexported fields
}

Set collect multiple TagLists and provides methods for merging them into a single, common TagList which can be applied to all instances of a duplicated file.

func NewSet

func NewSet() *Set

NewSet creates a new TagSet

func (*Set) AddTagList

func (ts *Set) AddTagList(tl List)

AddTagList adds an ordered list of tags to the set (for eventual merging)

func (*Set) ClearPreferredTags

func (ts *Set) ClearPreferredTags()

ClearPreferredTags removes all tag preferences, reverting to the most recently used name and color of each tag.

func (*Set) MergedTagList

func (ts *Set) MergedTagList() List

MergedTagList returns a TagList containing the full set of tags found in all TagLists within this TagSet, in an order that should keep the original order in tact as much as possible, while favouring later TagLists over earlier tag lists.

func (*Set) PreferTag

func (ts *Set) PreferTag(t *Tag)

PreferTag can be used to override the derived representation of a tag with a user-selected preference.

Note that this overrides both the tag's name as well as its color

func (*Set) TagColors

func (ts *Set) TagColors(id string) []string

TagColors returns the full list of colors that were used for a tag within this TagSet

func (*Set) TagLists

func (ts *Set) TagLists() []List

TagLists returns the list of tagLists, in the order they were added to this TagSet

func (*Set) TagNames

func (ts *Set) TagNames(id string) []string

TagNames returns the full list of names that were used for a tag within this TagSet

type Tag

type Tag struct {
	// contains filtered or unexported fields
}

Tag represents a single tag, with a name and color

func New added in v0.0.10

func New(name, color string) *Tag

New creates a new tag with a name and color.

The color may be a color id ("0" .. "7") or name ("none", "red", "orange", "yellow", "green", "blue", "purple", "grey"). Any other color strings will be translate to the color None

An empty string may be provided for either name or color, however, nil will be returned if neither name nor color are defined.

func (*Tag) Color

func (t *Tag) Color() string

Color returns the color of the tag as a simple string

func (*Tag) HasColor added in v0.0.10

func (t *Tag) HasColor() bool

func (*Tag) ID

func (t *Tag) ID() string

ID returns a lower-case representation of a tag, with all non-alphanumeric characters replaced by spaces.

func (*Tag) Name

func (t *Tag) Name() string

Name returns the name of the tag

func (*Tag) SetColor

func (t *Tag) SetColor(color string)

func (*Tag) String

func (t *Tag) String() string

String provides a string containing the tag's name and the name of its color

Jump to

Keyboard shortcuts

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