Documentation ΒΆ
Index ΒΆ
- Constants
- func ExistDir(path string) bool
- func ExistFile(path string) bool
- func IsURL(path string) bool
- type Arg
- type Argf
- type CompressedEntry
- type Config
- type Counter
- type CounterType
- type Either
- type Entry
- type FileEntry
- type Generator
- type Ignore
- type NameAndIndex
- type Order
- type Printer
- type Progress
- type ProgressBar
- type ReadOptions
- type Result
- type ResultSet
- type RuntimeOptions
- type Sizer
- type TarEntry
- type URLEntry
- type Wildcat
- type ZipEntry
Constants ΒΆ
const ( // Bytes shows the counter type for counting byte size. Bytes CounterType = 1 // Characters shows the counter type for counting characters. Characters = 2 // Words shows the counter type for counting the words. Words = 4 // Lines shows the counter type for counting the lines. Lines = 8 // All shows the counter type for counting byte size, characters, words, and lines. All = Lines | Words | Characters | Bytes )
Variables ΒΆ
This section is empty.
Functions ΒΆ
func ExistDir ΒΆ
ExistDir examines the given path is the directory. If given path is not found or is not a directory, this function returns false.
Types ΒΆ
type Arg ΒΆ added in v1.1.0
type Arg struct {
// contains filtered or unexported fields
}
Arg represents the one of command line arguments and its index.
func NewArgWithIndex ΒΆ added in v1.1.1
NewArgWithIndex creates an instance of Arg with given parameters.
type Argf ΒΆ
type Argf struct { Options *ReadOptions RuntimeOpts *RuntimeOptions Arguments []*Arg }
Argf shows the command line arguments and stdin (if no command line arguments).
func NewArgf ΒΆ
func NewArgf(arguments []string, opts *ReadOptions, runtimeOpts *RuntimeOptions) *Argf
NewArgf creates an instance of Argf for treating command line arguments.
type CompressedEntry ΒΆ added in v1.1.0
type CompressedEntry struct {
// contains filtered or unexported fields
}
func (*CompressedEntry) Count ΒΆ added in v1.1.0
func (ce *CompressedEntry) Count(generator Generator) *Either
func (*CompressedEntry) Index ΒΆ added in v1.1.0
func (ce *CompressedEntry) Index() *Order
func (*CompressedEntry) Name ΒΆ added in v1.1.0
func (ce *CompressedEntry) Name() string
func (*CompressedEntry) Open ΒΆ added in v1.1.0
func (ce *CompressedEntry) Open() (iowrapper.ReadCloseTypeParser, error)
type Config ΒΆ added in v1.1.0
type Config struct {
// contains filtered or unexported fields
}
Config is the configuration object for counting.
func NewConfig ΒΆ added in v1.1.0
func NewConfig(ignore Ignore, opts *ReadOptions, runtimeOpts *RuntimeOptions, ec *errors.Center) *Config
NewConfig creates an instance of Config.
type Counter ΒΆ
type Counter interface { IsType(ct CounterType) bool Type() CounterType Count(ct CounterType) int64 // contains filtered or unexported methods }
Counter shows
func NewCounter ΒΆ
func NewCounter(counterType CounterType) Counter
NewCounter generates Counter by CounterTypes.
type CounterType ΒΆ
type CounterType int
CounterType represents the types of counting.
func (CounterType) IsType ΒΆ
func (ct CounterType) IsType(ct2 CounterType) bool
IsType checks the equality between the receiver and the given counter type.
type Either ΒΆ added in v1.1.0
Either shows either the list of result or error.
func CountDefault ΒΆ added in v1.1.0
CountDefault is the default routine for counting.
type Entry ΒΆ
type Entry interface { NameAndIndex Count(generator Generator) *Either Open() (iowrapper.ReadCloseTypeParser, error) }
Entry shows the input for the each line in the results.
func ConvertToArchiveEntry ΒΆ added in v1.1.0
type FileEntry ΒΆ added in v1.1.0
type FileEntry struct {
// contains filtered or unexported fields
}
func NewFileEntry ΒΆ added in v1.1.0
func NewFileEntryWithIndex ΒΆ added in v1.1.0
func NewFileEntryWithIndex(nai NameAndIndex) *FileEntry
type Generator ΒΆ
type Generator func() Counter
Generator is the type for generating Counter object.
var DefaultGenerator Generator = func() Counter { return NewCounter(All) }
DefaultGenerator is the default generator for counting all (bytes, characters, words, and lines).
type Ignore ΒΆ
Ignore is an interface for checking the given path is the ignoring target or not.
func NewNoIgnore ΒΆ added in v1.1.0
func NewNoIgnore() Ignore
NewNoIgnore creates an instance of Ignore to ignore nothing.
type NameAndIndex ΒΆ added in v1.1.0
NameAndIndex means that the implemented object has the name and index.
func NormalizePath ΒΆ added in v1.2.0
func NormalizePath(arg NameAndIndex) NameAndIndex
type Order ΒΆ added in v1.1.1
type Order struct {
// contains filtered or unexported fields
}
Order shows the order of printing result.
func NewOrderWithIndex ΒΆ added in v1.1.1
NewOrderWithIndex creates an instance of Order.
func ParseOrder ΒΆ added in v1.1.1
ParseOrder parses the given string and creates an instance of Order.
func (*Order) Compare ΒΆ added in v1.1.1
Compare compares the receiver instance and the given order. If order < other, returns -1
order == other, return 0 order > other, return 1
type Printer ΒΆ
type Printer interface { PrintHeader(ct CounterType) PrintEach(fileName string, counter Counter, index int) PrintTotal(rs *ResultSet) }
Printer prints the result through ResultSet.
func NewPrinter ΒΆ
NewPrinter generates the suitable printer specified by given printerType to given dest. Available printerType are: "json", "xml", "csv", and "default" (case insensitive). If unknown type was given, the DefaultPrinter is returned.
type Progress ΒΆ added in v1.2.0
type Progress interface { UpdateTarget() Wait() Done() }
func NewProgress ΒΆ added in v1.2.0
type ProgressBar ΒΆ added in v1.2.0
type ProgressBar struct {
// contains filtered or unexported fields
}
func (*ProgressBar) Done ΒΆ added in v1.2.0
func (pb *ProgressBar) Done()
func (*ProgressBar) UpdateTarget ΒΆ added in v1.2.0
func (pb *ProgressBar) UpdateTarget()
func (*ProgressBar) Wait ΒΆ added in v1.2.0
func (pb *ProgressBar) Wait()
type ReadOptions ΒΆ
ReadOptions represents the set of options about reading file.
type Result ΒΆ added in v1.1.0
type Result struct {
// contains filtered or unexported fields
}
Result is the counted result of each entry.
type ResultSet ΒΆ
type ResultSet struct {
// contains filtered or unexported fields
}
ResultSet shows the set of results.
func (*ResultSet) Counter ΒΆ
Counter returns the object of Counter corresponding the given fileName.
func (*ResultSet) CounterType ΒΆ
func (rs *ResultSet) CounterType() CounterType
CounterType returns the types of counter of the ResultSet.
func (*ResultSet) Print ΒΆ
Print prints the content of receiver ResultSet instance through given printer.
type RuntimeOptions ΒΆ added in v1.2.0
type Sizer ΒΆ added in v1.0.3
type Sizer interface {
Convert(number int64, t CounterType) string
}
Sizer is an interface for representing a counted number.
func BuildSizer ΒΆ added in v1.0.3
BuildSizer creates an suitable instance of Sizer by the given flag.
type Wildcat ΒΆ added in v1.1.1
type Wildcat struct {
// contains filtered or unexported fields
}
Wildcat is the struct treating to count the specified files, directories, and urls.
func NewWildcat ΒΆ added in v1.1.1
func NewWildcat(opts *ReadOptions, runtimeOpts *RuntimeOptions, generator Generator) *Wildcat
NewWildcat creates an instance of Wildcat.
func (*Wildcat) Close ΒΆ added in v1.1.1
func (wc *Wildcat) Close()
Close finishes the receiver object.