wh

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2023 License: MIT Imports: 7 Imported by: 1

README

wh

A which alternative with more options

GoDoc Go Report Card

The core functionality of wh is implemented as a Go module. An executable of the same name is also provided for command-line usage.

Usage

TODO

  -0	Delimit output with null ('\0') instead of newline ('\n')
  -F	Use fixed string matching (default true)
  -L	Follow symbolic links
  -a	Report all matching files
  -d depth
    	Limit directory traversal to depth levels (default 1)
  -e	Use regular expression pattern matching
  -g	Use glob pattern matching
  -i	Use case-insensitive matching
  -p path-list
    	Search only in path-list (can be specified multiple times)
  -q	Print nothing; status indicates match found
  -s count
    	Dereference up to count chains of symbolic links (-1 = unlimited)
  -w	Print warning and diagnostic messages

Installation

TODO

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Match

func Match(option Option, pattern string, sub ...string) (found []string, err error)

func MatchFixed

func MatchFixed(option Option, pattern string, sub ...string) ([]string, error)

MatchFixed returns the result of calling Match with the given string pattern used to match file names verbatim.

func MatchGlob

func MatchGlob(option Option, pattern string, sub ...string) ([]string, error)

MatchGlob returns the result of calling Match with the given string pattern used to match file names according to path.Match semantics.

func MatchRegexp

func MatchRegexp(option Option, pattern string, sub ...string) ([]string, error)

MatchRegexp returns the result of calling Match with the given string pattern used to match file names according to regexp.Regexp semantics.

func ValidPath

func ValidPath(s string) error

ValidPath reports whether the given string s contains invalid symbols for a file path.

Types

type Chain added in v0.2.0

type Chain []*Link

Chain holds a sequence of Link for a single path component.

func MakeChain added in v0.2.0

func MakeChain(link ...*Link) Chain

MakeChain creates a new Chain, initialized with the given list of Links.

func (*Chain) Add added in v0.2.0

func (c *Chain) Add(link ...*Link)

Add adds the given list of Links to a Chain.

func (*Chain) Head added in v0.2.0

func (c *Chain) Head() *Link

Head returns the first symlink in a Chain.

func (*Chain) String added in v0.2.0

func (c *Chain) String() string

String returns a graphical representation of a Chain.

type ErrInvalidPath

type ErrInvalidPath string

ErrInvalidPath represents an error for a path with invalid symbols.

func (ErrInvalidPath) Error

func (e ErrInvalidPath) Error() string

Error returns a descriptive error string for the receiver ErrInvalidPath e.

type ErrMaxDepth

type ErrMaxDepth int

ErrMaxDepth represents a condition when walking a file system where the number of descendent directories traversed is greater than maximum allowed.

func (ErrMaxDepth) Error

func (e ErrMaxDepth) Error() string

Error returns a descriptive error string for the receiver ErrMaxDepth e.

type ErrWalkDir

type ErrWalkDir []errWalkDir

ErrWalkDir represents a list of errors encountered when calling fs.WalkDir on their corresponding subdirectories.

func (ErrWalkDir) Error

func (e ErrWalkDir) Error() string

Error returns a descriptive error string for the receiver ErrWalkDir e.

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

Link holds a single symlink dereference in a Chain.

func NewLink(root string, name string, ent fs.DirEntry) *Link

NewLink returns a reference to a new Link, initialized with the given file system attributes.

func (*Link) Deref added in v0.2.0

func (l *Link) Deref() (d Link, err error)

Deref creates and returns a new Link initialized with the destination's file system attributes of the receive symlink.

func (l *Link) IsSymlink() bool

IsSymlink returns true if and only if the Link has symlink mode bits set.

func (*Link) Path added in v0.2.0

func (l *Link) Path() string

Path returns the result of joining the Link's file name to its parent directory.

type MatchFunc

type MatchFunc func(Option, string, ...string) ([]string, error)

MatchFunc is the signature of each of the exported matching functions.

type Option

type Option struct {
	FollowSymlinks bool      // Follow symlinks when recursing into subdirectories
	MaxFollow      int       // Maximum number symlink components to follow
	MaxDepth       int       // Maximum number of subdirectory recursions
	Expr           expr.Expr // Matching semantics of the given pattern
	IgnoreCase     bool      // Ignore case in matching semantics
	WorkingDir     string    // Current working directory
	// contains filtered or unexported fields
}

Option defines all search and match options for the exported Match functions.

Directories

Path Synopsis
cmd
wh Module
Package expr defines the supported types of match expressions.
Package expr defines the supported types of match expressions.

Jump to

Keyboard shortcuts

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