tree

package
v1.12.8 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package tree implements a tree for displaying hierarchical password store entries. It is loosely based on https://github.com/restic/restic/blob/master/internal/restic/tree.go

Index

Constants

View Source
const (
	// INF allows to have a full recursion until the leaves of a tree
	INF = -1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	Name     string
	Type     string
	Template bool
	Mount    bool
	Path     string
	Subtree  *Tree
}

Node is a tree node

func (Node) Equals

func (n Node) Equals(other Node) bool

Equals compares to another node

func (*Node) Len

func (n *Node) Len() int

Len returns the length of this subtree

type Nodes

type Nodes []*Node

Nodes is a slice of nodes which can be sorted

func (Nodes) Len

func (n Nodes) Len() int

func (Nodes) Less

func (n Nodes) Less(i, j int) bool

func (Nodes) Swap

func (n Nodes) Swap(i, j int)

type Root

type Root struct {
	Name    string
	Subtree *Tree
	Prefix  string
}

Root is the root of a tree

func New

func New(name string) *Root

New creates a new tree

func (*Root) AddFile

func (r *Root) AddFile(path string, _ string) error

AddFile adds a new file to the tree

func (*Root) AddMount

func (r *Root) AddMount(path, dest string) error

AddMount adds a new mount point to the tree

func (*Root) AddTemplate

func (r *Root) AddTemplate(path string) error

AddTemplate adds a template to the tree

func (*Root) FindFolder

func (r *Root) FindFolder(path string) (*Root, error)

FindFolder returns the subtree rooted at path

func (*Root) Format

func (r *Root) Format(maxDepth int) string

Format returns a pretty printed string of all nodes in and below this node, e.g. ├── baz

func (*Root) Len

func (r *Root) Len() int

Len returns the number of entries in this folder and all subfolder including this folder itself

func (*Root) List

func (r *Root) List(maxDepth int) []string

List returns a flat list of all files in this tree

func (*Root) ListFolders

func (r *Root) ListFolders(maxDepth int) []string

ListFolders returns a flat list of all folders in this tree

func (*Root) SetName

func (r *Root) SetName(n string)

SetName changes the name of this tree

func (*Root) String

func (r *Root) String() string

String returns the name of this tree

type Tree

type Tree struct {
	Nodes []*Node
}

Tree is a tree

func NewTree

func NewTree() *Tree

NewTree creates a new tree

func (*Tree) Equals

func (t *Tree) Equals(other *Tree) bool

Equals compares to another tree

func (*Tree) Insert

func (t *Tree) Insert(node *Node) (*Node, error)

Insert adds a new node at the right position

func (*Tree) Sort

func (t *Tree) Sort()

Sort ensures this tree is sorted

func (*Tree) String

func (t *Tree) String() string

String returns the name of this tree

Jump to

Keyboard shortcuts

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