clean

package
v1.8.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package clean provides a command to clean a directory.

Index

Constants

This section is empty.

Variables

View Source
var Command = &cli.Command{
	Name:      "clean",
	Usage:     "Clean a directory.",
	ArgsUsage: "path",
	Flags: []cli.Flag{
		&cli.BoolFlag{
			Name:        "dry-run",
			Value:       false,
			Usage:       "Dry run.",
			Destination: &dryRun,
		},
		&cli.DurationFlag{
			Name:        "eligible-for-cleaning-age",
			Value:       48 * time.Hour,
			Usage:       "Minimum age of .combined files to be eligible for cleaning.",
			Aliases:     []string{"cleaning-age"},
			Destination: &eligibleForCleaningAge,
		},
	},
	Action: func(cCtx *cli.Context) error {
		path := cCtx.Args().First()
		if path == "" {
			log.Error().Msg("arg[0] is empty")
			return errors.New("missing file path")
		}

		opts := []cleaner.Option{
			cleaner.WithEligibleAge(eligibleForCleaningAge),
		}

		if dryRun {
			opts = append(opts, cleaner.WithDryRun())
		}

		return cleaner.Clean(path, opts...)
	},
}

Command is the command for cleaning a directory.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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