Fixing find help message and behavior (#2320)

This commit is contained in:
Harshavardhana
2017-12-01 18:04:09 -08:00
committed by GitHub
parent 336e7f58bf
commit 65c582cd5b
2 changed files with 20 additions and 20 deletions
+14 -16
View File
@@ -83,7 +83,7 @@ var (
var findCmd = cli.Command{
Name: "find",
Usage: "Finds files which match the given set of parameters.",
Usage: "Search for files and objects.",
Action: mainFind,
Before: setGlobalsFromContext,
Flags: append(findFlags, globalFlags...),
@@ -123,37 +123,35 @@ FORMAT
{url} --> Substitutes to a shareable URL of the path.
EXAMPLES:
01. Find all files named foo from all buckets.
$ {{.HelpName}} s3 --name "file"
01. Find all "foo.jpg" in all buckets under "s3" account.
$ {{.HelpName}} s3 --name "foo.jpg"
02. Find all text files from mybucket.
02. Find all objects with ".txt" extension under "s3/mybucket".
$ {{.HelpName}} s3/mybucket --name "*.txt"
03. Print only the object names without the directory component under this bucket.
$ {{.HelpName}} s3/bucket --name "*" -print {base}
03. Find only the object names without the directory component under "s3/mybucket".
$ {{.HelpName}} s3/mybucket --name "*" -print {base}
04. Copy all jpeg files from AWS S3 "s3/photos" bucket to minio "play/photos" bucket.
$ {{.HelpName}} s3/photos --name "*.jpg" --exec "mc cp {} play/photos"
05. Find all jpeg images from any folder prefixed with "album".
04. Find all images with ".jpg" extension under "s3/photos", prefixed with "album".
$ {{.HelpName}} s3/photos --name "*.jpg" --path "*/album*/*"
06. Find all files with extensions jpeg, png, and gif using regex.
05. Find all images with ".jpg", ".png", and ".gif" extentions, using regex under "s3/photos".
$ {{.HelpName}} s3/photos --regex "(?i)\.(jpg|png|gif)$"
07. Find all jpeg images from "s3/bucket" and copy to minio "play/bucket" *continuously*.
06. Find all images with ".jpg" extension under "s3/bucket" and copy to "play/bucket" *continuously*.
$ {{.HelpName}} s3/bucket --name "*.jpg" --watch --exec "mc cp {} play/bucket"
08. Generate self expiring urls (7 days), for all objects between 64 MB, and 1 GB in size.
07. Find and generate public URLs valid for 7 days, for all objects between 64 MB, and 1 GB in size under "s3" account.
$ {{.HelpName}} s3 --larger 64MB --smaller 1GB --print {url}
09. Find all files under the s3 bucket which were created within a week.
08. Find all objects created in the last week under "s3/bucket".
$ {{.HelpName}} s3/bucket --newer 1w
10. Find all files which were created more than 6 months ago ignoring files ending in jpg.
09. Find all objects which were created more than 6 months ago, and exclude the ones with ".jpg"
extension under "s3".
$ {{.HelpName}} s3 --older 6m --ignore "*.jpg"
11. List all objects up to 3 levels subdirectory deep.
10. List all objects up to 3 levels sub-directory deep under "s3/bucket".
$ {{.HelpName}} s3/bucket --maxdepth 3
`,
+6 -4
View File
@@ -109,7 +109,7 @@ func execFind(command string) {
if err := cmd.Run(); err != nil {
console.Fatalln(err)
}
console.Println(out.String())
console.Print(out.String())
}
// watchFind - enables listening on the input path, listens for all file/object
@@ -218,11 +218,13 @@ func find(ctx *findContext, fileContent contentMessage) {
if !matchFind(ctx, fileContent) {
return
} // For all matching content
// proceed to either exec, format the output string.
switch {
case ctx.execCmd != "":
if ctx.execCmd != "" {
execFind(stringsReplace(ctx.execCmd, fileContent))
case ctx.printFmt != "":
return
}
if ctx.printFmt != "" {
fileContent.Key = stringsReplace(ctx.printFmt, fileContent)
}
printMsg(findMessage{fileContent})