CLI: Show --admin-password flag at the top in command help #2195 #2248

Short name was changed from -a to --pw after the --auth flag was added.
This commit is contained in:
Michael Mayer 2022-04-12 20:00:06 +02:00
parent 915ff42133
commit 04609d536d
4 changed files with 10 additions and 10 deletions

View file

@ -14,9 +14,14 @@ import (
// GlobalFlags describes global command-line parameters and flags.
var GlobalFlags = []cli.Flag{
cli.StringFlag{
Name: "admin-password, pw",
Usage: fmt.Sprintf("initial admin `PASSWORD`, must have at least %d characters", entity.PasswordLen),
EnvVar: "PHOTOPRISM_ADMIN_PASSWORD",
},
cli.StringFlag{
Name: "log-level, l",
Usage: "`VERBOSITY` of log messages: trace, debug, info, warning, error, fatal, or panic",
Usage: "log message verbosity `LEVEL` (trace, debug, info, warning, error, fatal, panic)",
Value: "info",
EnvVar: "PHOTOPRISM_LOG_LEVEL",
},
@ -30,11 +35,6 @@ var GlobalFlags = []cli.Flag{
Usage: "enable trace mode, show all log messages",
EnvVar: "PHOTOPRISM_TRACE",
},
cli.StringFlag{
Name: "admin-password, pw",
Usage: fmt.Sprintf("initial admin `PASSWORD`, must have at least %d characters", entity.PasswordLen),
EnvVar: "PHOTOPRISM_ADMIN_PASSWORD",
},
cli.BoolFlag{
Name: "auth, a",
Usage: "always require password authentication, overrides the public flag",

View file

@ -22,10 +22,10 @@ type Options struct {
Version string `json:"-"`
Copyright string `json:"-"`
PartnerID string `yaml:"-" json:"-" flag:"partner-id"`
AdminPassword string `yaml:"AdminPassword" json:"-" flag:"admin-password"`
LogLevel string `yaml:"LogLevel" json:"-" flag:"log-level"`
Debug bool `yaml:"Debug" json:"Debug" flag:"debug"`
Trace bool `yaml:"Trace" json:"Trace" flag:"Trace"`
AdminPassword string `yaml:"AdminPassword" json:"-" flag:"admin-password"`
Auth bool `yaml:"Auth" json:"-" flag:"auth"`
Public bool `yaml:"Public" json:"-" flag:"public"`
Test bool `yaml:"-" json:"Test,omitempty" flag:"test"`

View file

@ -15,10 +15,10 @@ func (c *Config) Table() (rows [][]string, cols []string) {
cols = []string{"Value", "Name"}
rows = [][]string{
{"admin-password", strings.Repeat("*", utf8.RuneCountInString(c.AdminPassword()))},
{"log-level", c.LogLevel().String()},
{"debug", fmt.Sprintf("%t", c.Debug())},
{"trace", fmt.Sprintf("%t", c.Trace())},
{"admin-password", strings.Repeat("*", utf8.RuneCountInString(c.AdminPassword()))},
{"auth", fmt.Sprintf("%t", c.Auth())},
{"public", fmt.Sprintf("%t", c.Public())},
{"read-only", fmt.Sprintf("%t", c.ReadOnly())},

View file

@ -187,6 +187,7 @@ func CliTestContext() *cli.Context {
config := NewTestOptions("config-cli")
globalSet := flag.NewFlagSet("test", 0)
globalSet.String("admin-password", config.DarktableBin, "doc")
globalSet.Bool("debug", false, "doc")
globalSet.String("storage-path", config.StoragePath, "doc")
globalSet.String("backup-path", config.StoragePath, "doc")
@ -199,7 +200,6 @@ func CliTestContext() *cli.Context {
globalSet.String("cache-path", config.OriginalsPath, "doc")
globalSet.String("darktable-cli", config.DarktableBin, "doc")
globalSet.String("darktable-blacklist", config.DarktableBlacklist, "doc")
globalSet.String("admin-password", config.DarktableBin, "doc")
globalSet.String("wakeup-interval", "1h34m9s", "doc")
globalSet.Bool("detect-nsfw", config.DetectNSFW, "doc")
globalSet.Int("auto-index", config.AutoIndex, "doc")
@ -210,6 +210,7 @@ func CliTestContext() *cli.Context {
c := cli.NewContext(app, globalSet, nil)
LogError(c.Set("admin-password", config.AdminPassword))
LogError(c.Set("storage-path", config.StoragePath))
LogError(c.Set("backup-path", config.BackupPath))
LogError(c.Set("sidecar-path", config.SidecarPath))
@ -221,7 +222,6 @@ func CliTestContext() *cli.Context {
LogError(c.Set("cache-path", config.CachePath))
LogError(c.Set("darktable-cli", config.DarktableBin))
LogError(c.Set("darktable-blacklist", "raf,cr3"))
LogError(c.Set("admin-password", config.AdminPassword))
LogError(c.Set("wakeup-interval", "1h34m9s"))
LogError(c.Set("detect-nsfw", "true"))
LogError(c.Set("auto-index", strconv.Itoa(config.AutoIndex)))