- Replace copyright headers: "MinIO, Inc." -> "Hanzo AI, Inc." across 411+ Go files - Replace "MinIO Object Storage stack" -> "Hanzo S3 stack" in all file headers - Replace all user-facing "MinIO" references -> "Hanzo S3" in Usage, help text, examples - Replace example alias "myminio" -> "mys3" throughout - Replace example endpoints play.min.io -> s3.hanzo.ai, dl.min.io -> s3.hanzo.ai - Replace doc URLs min.io -> hanzo.space - Rewrite README.md/README_zh_CN.md: product is "Hanzo S3 CLI" (the s3 command) - Update CONTRIBUTING.md, CONFLICT.md, NOTICE, code_of_conduct.md - Update all Dockerfiles: labels, entrypoints, image refs -> ghcr.io/hanzos3/cli - Update Makefile: build output, docker tags, install paths -> s3 - Update docker-buildx.sh: image tags -> ghcr.io/hanzos3/cli - DO NOT change go.mod module path or import paths (github.com/minio/mc preserved) - DO NOT change Go identifiers, SDK types, or wire protocol constants - All unit tests pass
85 lines
2.9 KiB
Go
85 lines
2.9 KiB
Go
// Copyright (c) 2015-2022 Hanzo AI, Inc.
|
|
//
|
|
// This file is part of Hanzo S3 stack
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU Affero General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
package cmd
|
|
|
|
import (
|
|
"strings"
|
|
"text/tabwriter"
|
|
"text/template"
|
|
|
|
"github.com/fatih/color"
|
|
json "github.com/minio/colorjson"
|
|
"github.com/minio/madmin-go/v3"
|
|
"github.com/minio/mc/pkg/probe"
|
|
)
|
|
|
|
// HelpTmpl template used by all sub-systems
|
|
const HelpTmpl = `{{if ne .SubSys ""}}{{colorBlueBold "KEY:"}}
|
|
{{if .MultipleTargets}}{{colorYellowBold .SubSys}}[:name]{{"\t"}}{{else}}{{colorYellowBold .SubSys}}{{"\t"}}{{end}}{{.Description}}
|
|
|
|
{{colorBlueBold "ARGS:"}}{{range .KeysHelp}}
|
|
{{if .Optional}}{{colorYellowBold .Key}}{{else}}{{colorRedBold .Key}}*{{end}}{{"\t"}}({{.Type}}){{"\t"}}{{.Description}}{{end}}{{else}}{{colorBlueBold "KEYS:"}}{{range .KeysHelp}}
|
|
{{colorGreenBold .Key}}{{"\t"}}{{.Description}}{{end}}{{end}}`
|
|
|
|
var funcMap = template.FuncMap{
|
|
"colorBlueBold": color.New(color.FgBlue, color.Bold).SprintfFunc(),
|
|
"colorYellowBold": color.New(color.FgYellow, color.Bold).SprintfFunc(),
|
|
"colorCyanBold": color.New(color.FgCyan, color.Bold).SprintFunc(),
|
|
"colorRedBold": color.New(color.FgRed, color.Bold).SprintfFunc(),
|
|
"colorGreenBold": color.New(color.FgGreen, color.Bold).SprintfFunc(),
|
|
}
|
|
|
|
// HelpTemplate - captures config help template
|
|
var HelpTemplate = template.Must(template.New("config-help").Funcs(funcMap).Parse(HelpTmpl))
|
|
|
|
// HelpEnvTemplate - captures config help template
|
|
var HelpEnvTemplate = template.Must(template.New("config-help-env").Funcs(funcMap).Parse(HelpTmpl))
|
|
|
|
// configHelpMessage container to hold locks information.
|
|
type configHelpMessage struct {
|
|
Status string `json:"status"`
|
|
Value madmin.Help `json:"help"`
|
|
envOnly bool
|
|
}
|
|
|
|
// String colorized service status message.
|
|
func (u configHelpMessage) String() string {
|
|
var s strings.Builder
|
|
w := tabwriter.NewWriter(&s, 1, 8, 2, ' ', 0)
|
|
var e error
|
|
if !u.envOnly {
|
|
e = HelpTemplate.Execute(w, u.Value)
|
|
} else {
|
|
e = HelpEnvTemplate.Execute(w, u.Value)
|
|
}
|
|
fatalIf(probe.NewError(e), "Unable to initialize template writer")
|
|
|
|
w.Flush()
|
|
|
|
return s.String()
|
|
}
|
|
|
|
// JSON jsonified service status Message message.
|
|
func (u configHelpMessage) JSON() string {
|
|
u.Status = "success"
|
|
statusJSONBytes, e := json.MarshalIndent(u, "", " ")
|
|
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
|
|
|
return string(statusJSONBytes)
|
|
}
|