Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( TextCmd = &cobra.Command{ Use: "text", Short: "searches the texts in files which has desired file name pattern and string pattern in it (supports regex)", SilenceUsage: true, SilenceErrors: true, Example: `# search a text on target bucket by specifying regex for files s3-manager search text "catch me if you can" --file-name=".*.txt" `, PreRunE: func(cmd *cobra.Command, args []string) error { svc, searchOpts, logger = utils.PrepareConstants(cmd, options.GetSearchOptions()) if err := utils.CheckFlags(args); err != nil { logger.Error().Msg(err.Error()) return err } searchOpts.Text = args[0] return nil }, RunE: func(cmd *cobra.Command, args []string) (err error) { logger.Info(). Str("fileName", searchOpts.FileName). Msg("trying to search files on target bucket") matchedFiles, errs := aws.SearchString(svc, searchOpts) if len(errs) != 0 { err := fmt.Errorf("multiple errors occurred while searching files, try to target individual files %s", errs) logger.Error().Str("error", err.Error()) return err } if len(matchedFiles) == 0 { logger.Info(). Any("matchedFiles", matchedFiles). Str("text", searchOpts.Text). Msg("no matched files on the bucket") return nil } logger.Info(). Str("text", searchOpts.Text). Msg("fetched below matching files") for _, v := range matchedFiles { fmt.Println(v) } return nil }, } )
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.