cmd

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AppFs = afero.NewOsFs()

AppFs is a layer of abstraction for the filesystem

View Source
var RootCmd = &cobra.Command{
	Use:   "rot",
	Short: `rot empowers you to stage files and folders for rotting (later deletion).`,
}

RootCmd represents the base command when called without any subcommands

Functions

func Execute

func Execute()

Execute adds all child commands to the root command sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

Types

type RotItem

type RotItem struct {
	Path             string    `json:"path"`
	IsFolder         bool      `json:"is_folder,omitempty"`
	Hash             string    `json:"hash"` // currently SHA-256
	DeleteIfModified bool      `json:"delete_if_modified,omitempty"`
	AddedAt          time.Time `json:"added_at"`
	DeleteAt         time.Time `json:"delete_at,omitempty"`
}

RotItem is modelling one file or folder to rot

func NewRotItem

func NewRotItem(path string, deleteIfModified bool) (RotItem, error)

NewRotItem returns a new RotItem if the referenced path exists

func (RotItem) Clean

func (r RotItem) Clean(referenceDate time.Time, dryRun bool) (deleted bool, err error)

Clean removes this item if it is rotten at the given date.

func (RotItem) HasChanged

func (r RotItem) HasChanged() bool

HasChanged determines if the referenced item has changed since being staged for rotting.

func (RotItem) IsRotten

func (r RotItem) IsRotten(referenceDate time.Time) bool

IsRotten determines if the referenced item could be deleted at given time.

func (*RotItem) SetDeletionDate

func (r *RotItem) SetDeletionDate(deletionDate time.Time)

SetDeletionDate sets the date for deletion of the referenced item

func (*RotItem) SetDeletionDuration

func (r *RotItem) SetDeletionDuration(deletionDuration string)

SetDeletionDuration sets the date for deletion of the referenced item by supplying an ISO 8601 duration string

Jump to

Keyboard shortcuts

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