file

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: May 27, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrTooManyArguments = "too many arguments. please provide target file name. regex is accepted"
	ErrNoArgument       = "no argument provided. 'file' subcommand takes your desired file name to search in target bucket"
)

Variables

View Source
var (
	FileCmd = &cobra.Command{
		Use:          "file",
		Short:        "",
		SilenceUsage: true,
		PreRunE: func(cmd *cobra.Command, args []string) error {
			svc = cmd.Context().Value(rootopts.S3SvcKey{}).(s3iface.S3API)
			rootOpts := cmd.Context().Value(rootopts.OptsKey{}).(*rootopts.RootOptions)
			searchOpts.RootOptions = rootOpts

			logger = logging.GetLogger(searchOpts.RootOptions)

			if err := checkFlags(logger, args); err != nil {
				return err
			}

			searchOpts.FileName = args[0]

			return nil
		},
		RunE: func(cmd *cobra.Command, args []string) (err error) {

			files, err := aws.GetDesiredFiles(svc, searchOpts)
			if err != nil {
				logger.Error().
					Str("fileName", searchOpts.FileName).
					Str("error", err.Error()).
					Msg("an error occurred while fetching desired files")
				return err
			}

			if len(files) == 0 {
				logger.Warn().
					Str("fileName", searchOpts.FileName).
					Msg("no file found with the specified fileName or pattern")
				return nil
			}

			for _, v := range files {
				fmt.Println(v)
			}

			return nil
		},
	}
)

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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