add missing 'mc admin inspect' examples (#3934)

This commit is contained in:
Harshavardhana
2022-01-28 14:41:35 -08:00
committed by GitHub
parent 0c58d62a1f
commit f06a4b20a3
3 changed files with 38 additions and 15 deletions
+19 -1
View File
@@ -27,6 +27,8 @@ import (
"io/ioutil"
"os"
"path/filepath"
"runtime"
"strings"
"time"
"github.com/fatih/color"
@@ -62,7 +64,15 @@ USAGE:
FLAGS:
{{range .VisibleFlags}}{{.}}
{{end}}
EXAMPLES:
1. Download 'xl.meta' for a specific object from all the drives in a zip file.
{{.Prompt}} {{.HelpName}} myminio/bucket/test*/xl.meta
2. Download all constituent parts for a specific object, and optionally encrypt the downloaded zip.
{{.Prompt}} {{.HelpName}} --encrypt myminio/bucket/test*/*/part.*
3. Download recursively all objects at a prefix. NOTE: This can be an expensive operation use it with caution.
{{.Prompt}} {{.HelpName}} myminio/bucket/test/**
`,
}
@@ -97,7 +107,15 @@ func mainAdminInspect(ctx *cli.Context) error {
splits := splitStr(aliasedURL, "/", 3)
bucket, prefix := splits[1], splits[2]
key, r, ierr := client.Inspect(context.Background(), madmin.InspectOptions{Volume: bucket, File: prefix})
shellName, _ := getShellName()
if runtime.GOOS != "windows" && shellName != "bash" && strings.Contains(prefix, "*") {
console.Infoln("Your shell is auto determined as '" + shellName + "', wildcard patterns are only supported with 'bash' SHELL.")
}
key, r, ierr := client.Inspect(context.Background(), madmin.InspectOptions{
Volume: bucket,
File: prefix,
})
fatalIf(probe.NewError(ierr).Trace(aliasedURL), "Unable to inspect file.")
// Create profile zip file
+2
View File
@@ -58,10 +58,12 @@ EXAMPLES:
{{.DisableHistory}}
{{.Prompt}} {{.HelpName}} myminio foobar foo12345
{{.EnableHistory}}
2. Add a new user 'foobar' to MinIO server, prompting for keys.
{{.Prompt}} {{.HelpName}} myminio
Enter Access Key: foobar
Enter Secret Key: foobar12345
3. Add a new user 'foobar' to MinIO server using piped keys.
{{.DisableHistory}}
{{.Prompt}} echo -e "foobar\nfoobar12345" | {{.HelpName}} myminio
+17 -14
View File
@@ -36,6 +36,7 @@ import (
"github.com/inconshreveable/mousetrap"
"github.com/minio/cli"
"github.com/minio/mc/pkg/probe"
"github.com/minio/minio-go/v7/pkg/set"
"github.com/minio/pkg/console"
"github.com/minio/pkg/env"
"github.com/minio/pkg/trie"
@@ -299,12 +300,7 @@ func initMC() {
loadRootCAs()
}
func installAutoCompletion() {
if runtime.GOOS == "windows" {
console.Infoln("autocompletion feature is not available for this operating system")
return
}
func getShellName() (string, bool) {
shellName := os.Getenv("SHELL")
if shellName == "" {
ppid := os.Getppid()
@@ -315,19 +311,26 @@ func installAutoCompletion() {
"no SHELL environment variable found")
}
shellName = strings.TrimSpace(string(ppName))
return strings.ToLower(filepath.Base(shellName)), false
}
return strings.ToLower(filepath.Base(shellName)), true
}
func installAutoCompletion() {
if runtime.GOOS == "windows" {
console.Infoln("autocompletion feature is not available for this operating system")
return
}
shellName, ok := getShellName()
if !ok {
console.Infoln("No 'SHELL' env var. Your shell is auto determined as '" + shellName + "'.")
} else {
console.Infoln("Your shell is set to '" + shellName + "', by env var 'SHELL'.")
}
shellName = strings.ToLower(filepath.Base(shellName))
supportedShells := map[string]bool{
"bash": true,
"zsh": true,
"fish": true,
}
if !supportedShells[shellName] {
supportedShellsSet := set.CreateStringSet("bash", "zsh", "fish")
if !supportedShellsSet.Contains(shellName) {
fatalIf(probe.NewError(errors.New("")),
"'"+shellName+"' is not a supported shell. "+
"Supported shells are: bash, zsh, fish")