application

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2022 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const Reset = "\x1b[0m"

Reset undoes ANSI color codes

View Source
const VERSION = "1.1.0"

Variables

View Source
var FileAliases = map[string]string{}/* 158 elements not displayed */

Functions

func NewATimeGetter

func NewATimeGetter(colors bool, params *TimeParams) table.Getter

func NewCTimeGetter

func NewCTimeGetter(colors bool, params *TimeParams) table.Getter

func NewFileNameGetter

func NewFileNameGetter(colors bool, params *FileNameParams) table.Getter

func NewGroupGetter

func NewGroupGetter(colors bool) table.Getter

func NewMTimeGetter

func NewMTimeGetter(colors bool, params *TimeParams) table.Getter

func NewModeGetter

func NewModeGetter(colors bool) table.Getter

func NewOctalModeGetter

func NewOctalModeGetter(colors bool) table.Getter

func NewOwnerGetter

func NewOwnerGetter(colors bool) table.Getter

func NewSizeGetter

func NewSizeGetter(colors bool, format SizeFormat) table.Getter

func Run

func Run(rawArgs []string)

func Strftime

func Strftime(tm *time.Time, fmt string) string

Types

type ATimeGetter

type ATimeGetter struct {
	*TimeGetter
}

func (*ATimeGetter) Value

func (f *ATimeGetter) Value(item any) (any, error)

func (*ATimeGetter) ValueString

func (f *ATimeGetter) ValueString(colName string, item any) (string, error)

type ATimeGetterPlain

type ATimeGetterPlain struct {
	*TimeGetterPlain
}

func (*ATimeGetterPlain) Value

func (f *ATimeGetterPlain) Value(item any) (any, error)

func (*ATimeGetterPlain) ValueString

func (f *ATimeGetterPlain) ValueString(colName string, item any) (string, error)

type Application

type Application struct {
	iface.FileSystem
	iface.Terminal
	iface.Formatter

	Platform *lsplatform.LocalPlatform

	PrimaryTimeColName string
	QuotingStyle       string
	// contains filtered or unexported fields
}

func NewApplication

func NewApplication() *Application

func (*Application) AddError

func (app *Application) AddError(err error)

func (*Application) Exit

func (app *Application) Exit()

func (*Application) ListDir

func (app *Application) ListDir(tableObj *table.Table, path string)

func (*Application) ListDirList

func (app *Application) ListDirList(tableSpec *table.TableSpec, pathList []string)

func (*Application) ListFiles

func (app *Application) ListFiles(tableObj *table.Table, parentDir string, infoList []*FileInfo, forceDotfiles bool)

func (*Application) PostParse

func (app *Application) PostParse(args *lsargs.Arguments) *table.TableSpec

func (*Application) PrintErrors

func (app *Application) PrintErrors()

func (*Application) WorkDir

func (app *Application) WorkDir() string

type BlocksGetter

type BlocksGetter struct{}

func (*BlocksGetter) Format

func (f *BlocksGetter) Format(item any, value any) (string, error)

func (*BlocksGetter) Value

func (f *BlocksGetter) Value(item any) (any, error)

func (*BlocksGetter) ValueString

func (f *BlocksGetter) ValueString(colName string, item any) (string, error)

type ByDirContentsCount

type ByDirContentsCount ItemSorter

sorts by the number of contents (files and directories) in directories directories always come before files and remember, this includes hidden contents as well, so to count manually, use `ls -A1` or `ls-go -a1`

func (ByDirContentsCount) Len

func (s ByDirContentsCount) Len() int

func (ByDirContentsCount) Less

func (s ByDirContentsCount) Less(i, j int) bool

func (ByDirContentsCount) Swap

func (s ByDirContentsCount) Swap(i, j int)

type ByExtension

type ByExtension ItemSorter

func (ByExtension) Len

func (s ByExtension) Len() int

func (ByExtension) Less

func (s ByExtension) Less(i, j int) bool

func (ByExtension) Swap

func (s ByExtension) Swap(i, j int)

type ByFileSize

type ByFileSize ItemSorter

ByFileSize sorts files by size, and directories by lowercased name and sort directories after files

func (ByFileSize) Len

func (s ByFileSize) Len() int

func (ByFileSize) Less

func (s ByFileSize) Less(i, j int) bool

func (ByFileSize) Swap

func (s ByFileSize) Swap(i, j int)
type ByHardLinks ItemSorter

func (ByHardLinks) Len

func (s ByHardLinks) Len() int

func (ByHardLinks) Less

func (s ByHardLinks) Less(i, j int) bool

func (ByHardLinks) Swap

func (s ByHardLinks) Swap(i, j int)

type ByInode

type ByInode ItemSorter

func (ByInode) Len

func (s ByInode) Len() int

func (ByInode) Less

func (s ByInode) Less(i, j int) bool

func (ByInode) Swap

func (s ByInode) Swap(i, j int)

type ByKind

type ByKind ItemSorter

ByKind tells `sort.Sort` how to sort by file extension

func (ByKind) Len

func (s ByKind) Len() int

func (ByKind) Less

func (s ByKind) Less(i, j int) bool

func (ByKind) Swap

func (s ByKind) Swap(i, j int)

type ByNameLength

type ByNameLength ItemSorter

func (ByNameLength) Len

func (s ByNameLength) Len() int

func (ByNameLength) Less

func (s ByNameLength) Less(i, j int) bool

func (ByNameLength) Swap

func (s ByNameLength) Swap(i, j int)

type BySize

type BySize ItemSorter

sort by size in decending order

func (BySize) Len

func (s BySize) Len() int

func (BySize) Less

func (s BySize) Less(i, j int) bool

func (BySize) Swap

func (s BySize) Swap(i, j int)

type ByTime

type ByTime ItemSorter

sort by time (modified time by default) in decending order (newer first)

func (ByTime) Len

func (s ByTime) Len() int

func (ByTime) Less

func (s ByTime) Less(i, j int) bool

func (ByTime) Swap

func (s ByTime) Swap(i, j int)

type CTimeGetter

type CTimeGetter struct {
	*TimeGetter
}

func (*CTimeGetter) Value

func (f *CTimeGetter) Value(item any) (any, error)

func (*CTimeGetter) ValueString

func (f *CTimeGetter) ValueString(colName string, item any) (string, error)

type CTimeGetterPlain

type CTimeGetterPlain struct {
	*TimeGetterPlain
}

func (*CTimeGetterPlain) Value

func (f *CTimeGetterPlain) Value(item any) (any, error)

func (*CTimeGetterPlain) ValueString

func (f *CTimeGetterPlain) ValueString(colName string, item any) (string, error)

type DefaultSorter

type DefaultSorter ItemSorter

DefaultSorter is the default sorter for files and directories it first sorts by lowercased basename, then by extension

func (DefaultSorter) Len

func (s DefaultSorter) Len() int

func (DefaultSorter) Less

func (s DefaultSorter) Less(i, j int) bool

func (DefaultSorter) Swap

func (s DefaultSorter) Swap(i, j int)

type DisplayItem

type DisplayItem struct {
	*FileInfo
	Time    *time.Time
	Display []string
}

DisplayItem wraps the file stat info and string to be printed

type DisplayItemList

type DisplayItemList []*DisplayItem

func (DisplayItemList) Get

func (list DisplayItemList) Get(index int) []string

func (DisplayItemList) Len

func (list DisplayItemList) Len() int

type ExprGetter

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

func NewExprGetter

func NewExprGetter(colors bool, exprStr string) *ExprGetter

func (*ExprGetter) Alignment

func (f *ExprGetter) Alignment() (table.Alignment, error)

func (*ExprGetter) Format

func (f *ExprGetter) Format(item any, value any) (string, error)

func (*ExprGetter) MustValueBool

func (f *ExprGetter) MustValueBool(info *FileInfo) bool

func (*ExprGetter) Type

func (f *ExprGetter) Type() (reflect.Type, error)

func (*ExprGetter) Value

func (f *ExprGetter) Value(item any) (any, error)

func (*ExprGetter) ValueBool

func (f *ExprGetter) ValueBool(info *FileInfo) (bool, error)

func (*ExprGetter) ValueString

func (f *ExprGetter) ValueString(colName string, item any) (string, error)

type FileInfo

type FileInfo struct {
	fs.FileInfo

	Basename string
	Ext      string
	Suffix   string

	Dir    string
	CurDir string
	IsAbs  bool
	// contains filtered or unexported fields
}

func (*FileInfo) DirAbs

func (info *FileInfo) DirAbs() string

func (*FileInfo) Group

func (info *FileInfo) Group() string

func (*FileInfo) Owner

func (info *FileInfo) Owner() string

func (*FileInfo) PathAbs

func (info *FileInfo) PathAbs() string

func (*FileInfo) PathDisplay

func (info *FileInfo) PathDisplay() string

func (*FileInfo) Time

func (info *FileInfo) Time(colName string) *time.Time

type FileInfoLow

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

func NewFileInfoLowFrom

func NewFileInfoLowFrom(fi fs.FileInfo) *FileInfoLow

func (*FileInfoLow) IsDir

func (fi *FileInfoLow) IsDir() bool

func (*FileInfoLow) ModTime

func (fi *FileInfoLow) ModTime() time.Time

func (*FileInfoLow) Mode

func (fi *FileInfoLow) Mode() fs.FileMode

func (*FileInfoLow) Name

func (fi *FileInfoLow) Name() string

func (*FileInfoLow) Size

func (fi *FileInfoLow) Size() int64

func (*FileInfoLow) Sys

func (fi *FileInfoLow) Sys() any

type FileNameGetter

type FileNameGetter struct {
	*FileNameParams
}

func (*FileNameGetter) Format

func (f *FileNameGetter) Format(item any, value any) (string, error)

func (*FileNameGetter) Value

func (f *FileNameGetter) Value(item any) (any, error)

func (*FileNameGetter) ValueString

func (f *FileNameGetter) ValueString(colName string, item any) (string, error)

type FileNameGetterPlain

type FileNameGetterPlain struct {
	*FileNameParams
}

func (*FileNameGetterPlain) Format

func (f *FileNameGetterPlain) Format(item any, value any) (string, error)

func (*FileNameGetterPlain) Value

func (f *FileNameGetterPlain) Value(item any) (any, error)

func (*FileNameGetterPlain) ValueString

func (f *FileNameGetterPlain) ValueString(colName string, item any) (string, error)

type FileNameParams

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

type GroupGetter

type GroupGetter struct{}

func (*GroupGetter) Format

func (f *GroupGetter) Format(item any, value any) (string, error)

func (*GroupGetter) Value

func (f *GroupGetter) Value(item any) (any, error)

func (*GroupGetter) ValueString

func (f *GroupGetter) ValueString(colName string, item any) (string, error)

type GroupGetterPlain

type GroupGetterPlain struct{}

func (*GroupGetterPlain) Format

func (f *GroupGetterPlain) Format(item any, value any) (string, error)

func (*GroupGetterPlain) Value

func (f *GroupGetterPlain) Value(item any) (any, error)

func (*GroupGetterPlain) ValueString

func (f *GroupGetterPlain) ValueString(colName string, item any) (string, error)

type HardLinksGetter

type HardLinksGetter struct{}

func (*HardLinksGetter) Format

func (f *HardLinksGetter) Format(item any, value any) (string, error)

func (*HardLinksGetter) Value

func (f *HardLinksGetter) Value(item any) (any, error)

func (*HardLinksGetter) ValueString

func (f *HardLinksGetter) ValueString(colName string, item any) (string, error)

type InodeGetter

type InodeGetter struct{}

func (*InodeGetter) Format

func (f *InodeGetter) Format(item any, value any) (string, error)

func (*InodeGetter) Value

func (f *InodeGetter) Value(item any) (any, error)

func (*InodeGetter) ValueString

func (f *InodeGetter) ValueString(colName string, item any) (string, error)

type ItemSorter

type ItemSorter []*DisplayItem

type LinkInfo

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

LinkInfo wraps link stat info and whether the link points to valid file

func (*LinkInfo) Dereference

func (link *LinkInfo) Dereference(source *FileInfo) *FileInfo

type MTimeGetter

type MTimeGetter struct {
	*TimeGetter
}

func (*MTimeGetter) Value

func (f *MTimeGetter) Value(item any) (any, error)

func (*MTimeGetter) ValueString

func (f *MTimeGetter) ValueString(colName string, item any) (string, error)

type MTimeGetterPlain

type MTimeGetterPlain struct {
	*TimeGetterPlain
}

func (*MTimeGetterPlain) Value

func (f *MTimeGetterPlain) Value(item any) (any, error)

func (*MTimeGetterPlain) ValueString

func (f *MTimeGetterPlain) ValueString(colName string, item any) (string, error)

type ModeGetter

type ModeGetter struct{}

func (*ModeGetter) Format

func (f *ModeGetter) Format(item any, value any) (string, error)

func (*ModeGetter) Value

func (f *ModeGetter) Value(item any) (any, error)

func (*ModeGetter) ValueString

func (f *ModeGetter) ValueString(colName string, item any) (string, error)

type ModeGetterPlain

type ModeGetterPlain struct{}

func (*ModeGetterPlain) Format

func (f *ModeGetterPlain) Format(item any, value any) (string, error)

func (*ModeGetterPlain) Value

func (f *ModeGetterPlain) Value(item any) (any, error)

func (*ModeGetterPlain) ValueString

func (f *ModeGetterPlain) ValueString(colName string, item any) (string, error)

type OctModeGetter

type OctModeGetter struct{}

func (*OctModeGetter) Format

func (f *OctModeGetter) Format(item any, value any) (string, error)

func (*OctModeGetter) Value

func (f *OctModeGetter) Value(item any) (any, error)

func (*OctModeGetter) ValueString

func (f *OctModeGetter) ValueString(colName string, item any) (string, error)

type OwnerGetter

type OwnerGetter struct{}

func (*OwnerGetter) Format

func (f *OwnerGetter) Format(item any, value any) (string, error)

func (*OwnerGetter) Value

func (f *OwnerGetter) Value(item any) (any, error)

func (*OwnerGetter) ValueString

func (f *OwnerGetter) ValueString(colName string, item any) (string, error)

type OwnerGetterPlain

type OwnerGetterPlain struct{}

func (*OwnerGetterPlain) Format

func (f *OwnerGetterPlain) Format(item any, value any) (string, error)

func (*OwnerGetterPlain) Value

func (f *OwnerGetterPlain) Value(item any) (any, error)

func (*OwnerGetterPlain) ValueString

func (f *OwnerGetterPlain) ValueString(colName string, item any) (string, error)

type SizeGetter

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

func (*SizeGetter) Format

func (f *SizeGetter) Format(item any, value any) (string, error)

func (*SizeGetter) Value

func (f *SizeGetter) Value(item any) (any, error)

func (*SizeGetter) ValueString

func (f *SizeGetter) ValueString(colName string, item any) (string, error)

type SizeGetterPlain

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

func (*SizeGetterPlain) Format

func (f *SizeGetterPlain) Format(item any, value any) (string, error)

func (*SizeGetterPlain) Value

func (f *SizeGetterPlain) Value(item any) (any, error)

func (*SizeGetterPlain) ValueString

func (f *SizeGetterPlain) ValueString(colName string, item any) (string, error)

type TimeGetter

type TimeGetter struct {
	*TimeParams
}

func (*TimeGetter) Format

func (f *TimeGetter) Format(item any, value any) (string, error)

type TimeGetterPlain

type TimeGetterPlain struct {
	*TimeParams
}

func (*TimeGetterPlain) Format

func (f *TimeGetterPlain) Format(item any, value any) (string, error)

Jump to

Keyboard shortcuts

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