mirror of
https://github.com/minio/minio.git
synced 2024-12-24 22:25:54 -05:00
Add global flags to all commands and subcommands (#2605)
This commit is contained in:
parent
ff99392102
commit
3e284162d7
@ -24,19 +24,6 @@ var commands = []cli.Command{}
|
|||||||
// Collection of minio commands currently supported in a trie tree.
|
// Collection of minio commands currently supported in a trie tree.
|
||||||
var commandsTree = newTrie()
|
var commandsTree = newTrie()
|
||||||
|
|
||||||
// Collection of minio flags currently supported.
|
|
||||||
var globalFlags = []cli.Flag{
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "config-dir, C",
|
|
||||||
Value: mustGetConfigPath(),
|
|
||||||
Usage: "Path to configuration folder.",
|
|
||||||
},
|
|
||||||
cli.BoolFlag{
|
|
||||||
Name: "quiet",
|
|
||||||
Usage: "Suppress chatty output.",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
// registerCommand registers a cli command.
|
// registerCommand registers a cli command.
|
||||||
func registerCommand(command cli.Command) {
|
func registerCommand(command cli.Command) {
|
||||||
commands = append(commands, command)
|
commands = append(commands, command)
|
||||||
|
@ -29,12 +29,17 @@ var healCmd = cli.Command{
|
|||||||
Name: "heal",
|
Name: "heal",
|
||||||
Usage: "To heal objects.",
|
Usage: "To heal objects.",
|
||||||
Action: healControl,
|
Action: healControl,
|
||||||
|
Flags: globalFlags,
|
||||||
CustomHelpTemplate: `NAME:
|
CustomHelpTemplate: `NAME:
|
||||||
minio control {{.Name}} - {{.Usage}}
|
minio control {{.Name}} - {{.Usage}}
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
minio control {{.Name}}
|
minio control {{.Name}}
|
||||||
|
|
||||||
|
FLAGS:
|
||||||
|
{{range .Flags}}{{.}}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
EXAMPLES:
|
EXAMPLES:
|
||||||
1. Heal an object.
|
1. Heal an object.
|
||||||
$ minio control {{.Name}} http://localhost:9000/songs/classical/western/piano.mp3
|
$ minio control {{.Name}} http://localhost:9000/songs/classical/western/piano.mp3
|
||||||
|
@ -97,12 +97,17 @@ var lockCmd = cli.Command{
|
|||||||
Name: "lock",
|
Name: "lock",
|
||||||
Usage: "info about the locks in the node.",
|
Usage: "info about the locks in the node.",
|
||||||
Action: lockControl,
|
Action: lockControl,
|
||||||
|
Flags: globalFlags,
|
||||||
CustomHelpTemplate: `NAME:
|
CustomHelpTemplate: `NAME:
|
||||||
minio control {{.Name}} - {{.Usage}}
|
minio control {{.Name}} - {{.Usage}}
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
minio control {{.Name}} http://localhost:9000/
|
minio control {{.Name}} http://localhost:9000/
|
||||||
|
|
||||||
|
FLAGS:
|
||||||
|
{{range .Flags}}{{.}}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
EAMPLES:
|
EAMPLES:
|
||||||
1. Get all the info about the blocked/held locks in the node:
|
1. Get all the info about the blocked/held locks in the node:
|
||||||
$ minio control lock http://localhost:9000/
|
$ minio control lock http://localhost:9000/
|
||||||
|
@ -22,6 +22,7 @@ import "github.com/minio/cli"
|
|||||||
var controlCmd = cli.Command{
|
var controlCmd = cli.Command{
|
||||||
Name: "control",
|
Name: "control",
|
||||||
Usage: "Control and manage minio server.",
|
Usage: "Control and manage minio server.",
|
||||||
|
Flags: globalFlags,
|
||||||
Action: mainControl,
|
Action: mainControl,
|
||||||
Subcommands: []cli.Command{
|
Subcommands: []cli.Command{
|
||||||
lockCmd,
|
lockCmd,
|
||||||
|
@ -23,22 +23,28 @@ import (
|
|||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
var shutdownCmd = cli.Command{
|
var shutdownFlags = []cli.Flag{
|
||||||
Name: "shutdown",
|
|
||||||
Usage: "Shutdown or restart the server.",
|
|
||||||
Action: shutdownControl,
|
|
||||||
Flags: []cli.Flag{
|
|
||||||
cli.BoolFlag{
|
cli.BoolFlag{
|
||||||
Name: "restart",
|
Name: "restart",
|
||||||
Usage: "Restart the server.",
|
Usage: "Restart the server.",
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
|
|
||||||
|
var shutdownCmd = cli.Command{
|
||||||
|
Name: "shutdown",
|
||||||
|
Usage: "Shutdown or restart the server.",
|
||||||
|
Action: shutdownControl,
|
||||||
|
Flags: append(shutdownFlags, globalFlags...),
|
||||||
CustomHelpTemplate: `NAME:
|
CustomHelpTemplate: `NAME:
|
||||||
minio control {{.Name}} - {{.Usage}}
|
minio control {{.Name}} - {{.Usage}}
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
minio control {{.Name}} http://localhost:9000/
|
minio control {{.Name}} http://localhost:9000/
|
||||||
|
|
||||||
|
FLAGS:
|
||||||
|
{{range .Flags}}{{.}}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
EXAMPLES:
|
EXAMPLES:
|
||||||
1. Shutdown the server:
|
1. Shutdown the server:
|
||||||
$ minio control shutdown http://localhost:9000/
|
$ minio control shutdown http://localhost:9000/
|
||||||
|
13
cmd/main.go
13
cmd/main.go
@ -27,11 +27,20 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
// global flags for minio.
|
// global flags for minio.
|
||||||
minioFlags = []cli.Flag{
|
globalFlags = []cli.Flag{
|
||||||
cli.BoolFlag{
|
cli.BoolFlag{
|
||||||
Name: "help, h",
|
Name: "help, h",
|
||||||
Usage: "Show help.",
|
Usage: "Show help.",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "config-dir, C",
|
||||||
|
Value: mustGetConfigPath(),
|
||||||
|
Usage: "Path to configuration folder.",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "quiet",
|
||||||
|
Usage: "Suppress chatty output.",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -115,7 +124,7 @@ func registerApp() *cli.App {
|
|||||||
app.Author = "Minio.io"
|
app.Author = "Minio.io"
|
||||||
app.Usage = "Cloud Storage Server."
|
app.Usage = "Cloud Storage Server."
|
||||||
app.Description = `Minio is an Amazon S3 compatible object storage server. Use it to store photos, videos, VMs, containers, log files, or any blob of data as objects.`
|
app.Description = `Minio is an Amazon S3 compatible object storage server. Use it to store photos, videos, VMs, containers, log files, or any blob of data as objects.`
|
||||||
app.Flags = append(minioFlags, globalFlags...)
|
app.Flags = globalFlags
|
||||||
app.Commands = commands
|
app.Commands = commands
|
||||||
app.CustomAppHelpTemplate = minioHelpTemplate
|
app.CustomAppHelpTemplate = minioHelpTemplate
|
||||||
app.CommandNotFound = func(ctx *cli.Context, command string) {
|
app.CommandNotFound = func(ctx *cli.Context, command string) {
|
||||||
|
@ -29,10 +29,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var srvConfig serverCmdConfig
|
var srvConfig serverCmdConfig
|
||||||
var serverCmd = cli.Command{
|
|
||||||
Name: "server",
|
var serverFlags = []cli.Flag{
|
||||||
Usage: "Start object storage server.",
|
|
||||||
Flags: []cli.Flag{
|
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "address",
|
Name: "address",
|
||||||
Value: ":9000",
|
Value: ":9000",
|
||||||
@ -42,7 +40,12 @@ var serverCmd = cli.Command{
|
|||||||
Name: "ignore-disks",
|
Name: "ignore-disks",
|
||||||
Usage: "Specify comma separated list of disks that are offline.",
|
Usage: "Specify comma separated list of disks that are offline.",
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
|
|
||||||
|
var serverCmd = cli.Command{
|
||||||
|
Name: "server",
|
||||||
|
Usage: "Start object storage server.",
|
||||||
|
Flags: append(serverFlags, globalFlags...),
|
||||||
Action: serverMain,
|
Action: serverMain,
|
||||||
CustomHelpTemplate: `NAME:
|
CustomHelpTemplate: `NAME:
|
||||||
minio {{.Name}} - {{.Usage}}
|
minio {{.Name}} - {{.Usage}}
|
||||||
|
@ -33,10 +33,6 @@ import (
|
|||||||
// command specific flags.
|
// command specific flags.
|
||||||
var (
|
var (
|
||||||
updateFlags = []cli.Flag{
|
updateFlags = []cli.Flag{
|
||||||
cli.BoolFlag{
|
|
||||||
Name: "help, h",
|
|
||||||
Usage: "Help for update.",
|
|
||||||
},
|
|
||||||
cli.BoolFlag{
|
cli.BoolFlag{
|
||||||
Name: "experimental, E",
|
Name: "experimental, E",
|
||||||
Usage: "Check experimental update.",
|
Usage: "Check experimental update.",
|
||||||
@ -49,7 +45,7 @@ var updateCmd = cli.Command{
|
|||||||
Name: "update",
|
Name: "update",
|
||||||
Usage: "Check for a new software update.",
|
Usage: "Check for a new software update.",
|
||||||
Action: mainUpdate,
|
Action: mainUpdate,
|
||||||
Flags: updateFlags,
|
Flags: append(updateFlags, globalFlags...),
|
||||||
CustomHelpTemplate: `Name:
|
CustomHelpTemplate: `Name:
|
||||||
minio {{.Name}} - {{.Usage}}
|
minio {{.Name}} - {{.Usage}}
|
||||||
|
|
||||||
|
@ -25,15 +25,25 @@ var versionCmd = cli.Command{
|
|||||||
Name: "version",
|
Name: "version",
|
||||||
Usage: "Print version.",
|
Usage: "Print version.",
|
||||||
Action: mainVersion,
|
Action: mainVersion,
|
||||||
|
Flags: globalFlags,
|
||||||
CustomHelpTemplate: `NAME:
|
CustomHelpTemplate: `NAME:
|
||||||
minio {{.Name}} - {{.Usage}}
|
minio {{.Name}} - {{.Usage}}
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
minio {{.Name}} {{if .Description}}
|
minio {{.Name}}
|
||||||
|
|
||||||
|
FLAGS:
|
||||||
|
{{range .Flags}}{{.}}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
|
|
||||||
func mainVersion(ctx *cli.Context) {
|
func mainVersion(ctx *cli.Context) {
|
||||||
|
if len(ctx.Args()) != 0 {
|
||||||
|
cli.ShowCommandHelpAndExit(ctx, "version", 1)
|
||||||
|
}
|
||||||
|
|
||||||
console.Println("Version: " + Version)
|
console.Println("Version: " + Version)
|
||||||
console.Println("Release-Tag: " + ReleaseTag)
|
console.Println("Release-Tag: " + ReleaseTag)
|
||||||
console.Println("Commit-ID: " + CommitID)
|
console.Println("Commit-ID: " + CommitID)
|
||||||
|
Loading…
Reference in New Issue
Block a user