trash

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")
View Source
var (
	ModeByFlagCompletionFunc = FlagCompletionFunc(
		maps.Keys(modeByWellKnownStrings),
	)
)
View Source
var (
	SortByFlagCompletionFunc = FlagCompletionFunc(
		maps.Keys(sortByWellKnownStrings),
	)
)

Functions

func FlagCompletionFunc

func FlagCompletionFunc(allCompletions []string) func(*cobra.Command, []string, string) (
	[]string, cobra.ShellCompDirective,
)

Types

type Box

type Box struct {
	Files           []File
	FilesByTrashDir map[string][]File // key: trash_dir, value: array of Files
	TrashDirs       []string

	OrphanMeta []File // .trashinfo exists but there is no real file in the files folder

	// Whether to use stat(2) to get size and mode
	GetSize bool
	// contains filtered or unexported fields
}

func NewBox

func NewBox(opts ...BoxOption) Box

func (*Box) HitByPath

func (b *Box) HitByPath(originalPath string) int

func (*Box) Open

func (b *Box) Open() error

func (*Box) ToGroups

func (b *Box) ToGroups() []Group

type BoxOption

type BoxOption func(*Box)

func WithAscend

func WithAscend(ascend bool) BoxOption

func WithCWD

func WithCWD(cwd bool) BoxOption

func WithDay

func WithDay(dayNew int, dayOld int) BoxOption

TODO: Support for notations other than day?

func WithDirectory

func WithDirectory(directory string) BoxOption

func WithGetSize

func WithGetSize(get bool) BoxOption

func WithLimitLast

func WithLimitLast(last int) BoxOption

func WithQueries

func WithQueries(queries []string) BoxOption

func WithQueryMode

func WithQueryMode(mode ModeByType) BoxOption

func WithSize

func WithSize(large string, small string) BoxOption

func WithSortBy

func WithSortBy(sortBy SortByType) BoxOption

func WithTrashDir added in v0.0.3

func WithTrashDir(trashDir string) BoxOption

type File

type File struct {
	Name          string    // .vimrc
	OriginalPath  string    // ~/.vimrc (Info.Path)
	TrashPath     string    // ~/.local/share/Trash/files/.vimrc
	TrashInfoPath string    // ~/.local/share/Trash/info/.vimrc.trashinfo
	DeletedAt     time.Time // 2023-01-01T00:00:00 (Info.DeletionDate)
	IsDir         bool
	// optionals below
	Size *int64 // nil if could not get, It may not be able to be taken due to permission violation, etc.
	Mode fs.FileMode
}

func (*File) Delete

func (f *File) Delete() error

func (*File) OriginalPathFormat

func (f *File) OriginalPathFormat(tilde bool, color bool) string

func (*File) SizeHuman

func (f *File) SizeHuman() string

func (*File) TrashPathColor

func (f *File) TrashPathColor() string

type Group

type Group struct {
	Dir         string
	IsDirCommon bool      // Whether Dir is the same for all files
	DeletedAt   time.Time // pick one from Files
	Files       []File
}

type ModeByType

type ModeByType int
const (
	ModeByRegex ModeByType = iota
	ModeByGlob             // default
	ModeByLiteral
	ModeByFull
)

func (*ModeByType) Set

func (s *ModeByType) Set(str string) error

func (ModeByType) String

func (s ModeByType) String() string

func (ModeByType) Type

func (s ModeByType) Type() string

type SortByType

type SortByType int
const (
	SortByDeletedAt SortByType = iota // default
	SortBySize
	SortByName
)

func (*SortByType) Set

func (s *SortByType) Set(str string) error

func (SortByType) String

func (s SortByType) String() string

func (SortByType) Type

func (s SortByType) Type() string

Jump to

Keyboard shortcuts

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