rm

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Command = &cli.Command{
	Name:      "rm",
	Usage:     "Delete GCS objects or local files",
	ArgsUsage: "[TARGET ...]",
	Action: func(ctx context.Context, cmd *cli.Command) error {
		if cmd.Args().Len() < 1 {
			return fmt.Errorf("%w: rm command requires at least 1 argument", utils.ErrInvalidArgs)
		}

		client, err := utils.NewClient(ctx)
		if err != nil {
			return fmt.Errorf("failed to create GCS client: %w", err)
		}
		defer client.Close()

		for _, arg := range cmd.Args().Slice() {
			if strings.HasPrefix(arg, "gs://") {
				bucket, object, _, err := utils.ParseGCSPath(arg)
				if err != nil {
					return err
				}
				if err := utils.RetryObject(utils.RetryBucket(client, bucket), object).Delete(ctx); err != nil {
					return fmt.Errorf("failed to delete GCS object %s: %w", arg, err)
				}
			} else {
				if err := os.Remove(arg); err != nil {
					return fmt.Errorf("failed to remove local file %s: %w", arg, err)
				}
			}
		}

		return nil
	},
}

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