ki

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: MIT Imports: 5 Imported by: 0

README

ki

ki is a small library and command to convert a list of paths into a tree.

Example

$ tar -c . | tar -t | ki
a
  b
    three.txt
  two.txt
one.txt

Documentation

Overview

Package ki creates tree structures from lists of file paths.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Tree

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

A Tree is a tree of paths. Each Tree instance is a directory in that path tree.

func Parse

func Parse(r io.Reader) (*Tree, error)

Parse parses a nweline-separated list of slash-separated paths and builds a tree from it.

func (*Tree) Add

func (t *Tree) Add(p string)

Add adds a single slash-separated path to the tree rooted at t.

func (*Tree) Children

func (t *Tree) Children(yield func(*Tree) bool)

Children yields the child trees of t in ascending alphabetical order.

func (*Tree) Name

func (t *Tree) Name() string

Name returns the name of the path element represented by t. If t is the root of a tree as returned by Parse, this will be the empty string.

func (*Tree) NumChildren

func (t *Tree) NumChildren() int

NumChildren returns the number of t's child trees.

func (*Tree) Parse

func (t *Tree) Parse(r io.Reader) error

Parse parses a newline-separated list of slash-separated paths and adds them to the tree rooted at t.

Directories

Path Synopsis
cmd
ki
ki is a tool for converting lists of paths into a tree.
ki is a tool for converting lists of paths into a tree.

Jump to

Keyboard shortcuts

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