entry

package
v0.0.0-...-0698f9f Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package entry provides functionality for listing directory entries with customizable formatting and cross-platform support.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrintEntries

func PrintEntries(path string, cfg Config) error

PrintEntries prints entries to stdout. It optionally recurses into subdirectories based on Config.Recurse.

func ResolvePath

func ResolvePath(f *flag.FlagSet) (string, error)

ResolvePath returns the first non-flag argument or the current directory.

Types

type Config

type Config struct {
	All     bool
	Grid    bool
	Long    bool
	Header  bool
	Recurse bool
	Size    bool
	Time    bool
	Kind    bool
	Ext     bool
	Reverse bool
}

Config holds command-line configuration options for directory listing.

func ParseConfig

func ParseConfig() (Config, *flag.FlagSet, error)

ParseConfig parses command-line flags and returns the configuration.

type Entry

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

Entry represents a file or directory with its metadata.

func ReadEntries

func ReadEntries(path string, cfg Config) ([]Entry, error)

ReadEntries reads and returns a slice of Entries from the specified path.

func (Entry) Name

func (e Entry) Name() string

Name returns the file name of the Entry, quoted if it has special characters or whitespace.

func (Entry) Permission

func (e Entry) Permission() string

Permission returns the file permissions of the Entry as a string.

func (Entry) Size

func (e Entry) Size() int64

Size returns the size of the Entry in bytes.

func (Entry) Time

func (e Entry) Time() string

Time returns the formatted modification time of the Entry. Uses "Jan 02 15:04" for current-year entries, "Jan 02 2006" otherwise.

func (Entry) UserAndGroup

func (e Entry) UserAndGroup() (string, string)

UserAndGroup returns the user and group names for the Entry's file info.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳