CLI: Revised descriptions of commands and configuration flags

This commit is contained in:
Michael Mayer 2021-10-07 13:00:32 +02:00
parent 874af1db61
commit 8a063037e0
5 changed files with 51 additions and 50 deletions

View file

@ -10,6 +10,7 @@ import (
"path/filepath"
"time"
"github.com/dustin/go-humanize/english"
"github.com/urfave/cli"
"github.com/photoprism/photoprism/internal/config"
@ -22,7 +23,7 @@ import (
// BackupCommand configures the backup cli command.
var BackupCommand = cli.Command{
Name: "backup",
Usage: "Creates index database and album backups",
Usage: "Creates index database dumps and optional YAML album backups",
UsageText: `A custom index sql backup FILENAME may be passed as first argument. Use - for stdout. By default, the backup path is searched.`,
Flags: backupFlags,
Action: backupAction,
@ -31,23 +32,23 @@ var BackupCommand = cli.Command{
var backupFlags = []cli.Flag{
cli.BoolFlag{
Name: "force, f",
Usage: "overwrite existing backup files",
Usage: "replace existing backup files",
},
cli.BoolFlag{
Name: "albums, a",
Usage: "create album yaml file backups",
Usage: "create album YAML backup files",
},
cli.StringFlag{
Name: "albums-path",
Usage: "custom album yaml file backup `PATH`",
Usage: "custom album backup `PATH`",
},
cli.BoolFlag{
Name: "index, i",
Usage: "create index sql database backup",
Usage: "create index database SQL dump",
},
cli.StringFlag{
Name: "index-path",
Usage: "custom index sql database backup `PATH`",
Usage: "custom index database backup `PATH`",
},
}
@ -179,7 +180,7 @@ func backupAction(ctx *cli.Context) error {
if count, err := photoprism.BackupAlbums(albumsPath, true); err != nil {
return err
} else {
log.Infof("%d albums saved as yaml files", count)
log.Infof("created %s", english.Plural(count, "YAML album backup file", "YAML album backup files"))
}
}

View file

@ -18,16 +18,16 @@ import (
// ResetCommand resets the index and removes sidecar files after confirmation.
var ResetCommand = cli.Command{
Name: "reset",
Usage: "Resets the index and removes sidecar files after confirmation",
Usage: "Resets the index and removes JSON / YAML sidecar files",
Action: resetAction,
}
// resetAction resets the index and removes sidecar files after confirmation.
func resetAction(ctx *cli.Context) error {
log.Warnf("'photoprism reset' resets the index and removes sidecar files after confirmation")
log.Warnf("YOU ARE ABOUT TO RESET THE INDEX AND REMOVE ALL JSON / YAML SIDECAR FILES")
removeIndexPrompt := promptui.Prompt{
Label: "Reset index database incl albums, labels, users and metadata?",
Label: "Reset index database incl all albums and metadata?",
IsConfirm: true,
}
@ -63,7 +63,7 @@ func resetAction(ctx *cli.Context) error {
}
removeSidecarJsonPrompt := promptui.Prompt{
Label: "Permanently remove all JSON photo sidecar files?",
Label: "Permanently delete existing JSON metadata sidecar files?",
IsConfirm: true,
}
@ -77,7 +77,7 @@ func resetAction(ctx *cli.Context) error {
}
if len(matches) > 0 {
log.Infof("removing %d JSON photo sidecar files", len(matches))
log.Infof("removing %d JSON metadata sidecar files", len(matches))
for _, name := range matches {
if err := os.Remove(name); err != nil {
@ -89,16 +89,16 @@ func resetAction(ctx *cli.Context) error {
fmt.Println("")
log.Infof("removed JSON sidecar files [%s]", time.Since(start))
log.Infof("removed JSON metadata sidecar files [%s]", time.Since(start))
} else {
log.Infof("found no JSON sidecar files")
log.Infof("found no JSON metadata sidecar files")
}
} else {
log.Infof("keeping JSON sidecar files")
log.Infof("keeping JSON metadata sidecar files")
}
removeSidecarYamlPrompt := promptui.Prompt{
Label: "Permanently remove all YAML photo metadata backup files?",
Label: "Permanently delete existing YAML metadata backups?",
IsConfirm: true,
}
@ -112,7 +112,7 @@ func resetAction(ctx *cli.Context) error {
}
if len(matches) > 0 {
log.Infof("%d YAML photo metadata backup files will be removed", len(matches))
log.Infof("%d YAML metadata backups will be removed", len(matches))
for _, name := range matches {
if err := os.Remove(name); err != nil {
@ -124,16 +124,16 @@ func resetAction(ctx *cli.Context) error {
fmt.Println("")
log.Infof("removed YAML photo metadata backup files [%s]", time.Since(start))
log.Infof("removed all YAML metadata backups [%s]", time.Since(start))
} else {
log.Infof("found no YAML photo metadata backup files")
log.Infof("found no YAML metadata backups")
}
} else {
log.Infof("keeping YAML photo metadata backup files")
log.Infof("keeping YAML metadata backups")
}
removeAlbumYamlPrompt := promptui.Prompt{
Label: "Permanently remove all YAML album backup files?",
Label: "Permanently delete existing YAML album backups?",
IsConfirm: true,
}
@ -159,7 +159,7 @@ func resetAction(ctx *cli.Context) error {
fmt.Println("")
log.Infof("removed YAML album backup files [%s]", time.Since(start))
log.Infof("removed all YAML album backups [%s]", time.Since(start))
} else {
log.Infof("found no YAML album backup files")
}

View file

@ -24,7 +24,7 @@ import (
// RestoreCommand configures the backup cli command.
var RestoreCommand = cli.Command{
Name: "restore",
Usage: "Restores index database and album backups",
Usage: "Restores the index from database dumps and YAML album backups",
UsageText: `A custom index sql backup FILENAME may be passed as first argument. By default, the backup path is searched.`,
Flags: restoreFlags,
Action: restoreAction,
@ -33,23 +33,23 @@ var RestoreCommand = cli.Command{
var restoreFlags = []cli.Flag{
cli.BoolFlag{
Name: "force, f",
Usage: "overwrite existing index",
Usage: "replace existing index",
},
cli.BoolFlag{
Name: "albums, a",
Usage: "restore album yaml file backups",
Usage: "restore albums from YAML files",
},
cli.StringFlag{
Name: "albums-path",
Usage: "custom album yaml file backup `PATH`",
Usage: "custom albums backup `PATH`",
},
cli.BoolFlag{
Name: "index, i",
Usage: "restore index sql database backup",
Usage: "restore index from SQL dump",
},
cli.StringFlag{
Name: "index-path",
Usage: "custom index sql database backup `PATH`",
Usage: "custom index backup `PATH`",
},
}

View file

@ -26,6 +26,11 @@ var GlobalFlags = []cli.Flag{
EnvVar: "PHOTOPRISM_LOG_FILENAME",
Value: "",
},
cli.StringFlag{
Name: "pid-filename",
Usage: "process id `FILENAME` when running in daemon mode",
EnvVar: "PHOTOPRISM_PID_FILENAME",
},
cli.BoolFlag{
Name: "test",
Hidden: true,
@ -111,7 +116,7 @@ var GlobalFlags = []cli.Flag{
},
cli.StringFlag{
Name: "backup-path",
Usage: "optional custom backup file `PATH`",
Usage: "optional custom backup `PATH` for index backup files",
EnvVar: "PHOTOPRISM_BACKUP_PATH",
},
cli.StringFlag{
@ -121,7 +126,7 @@ var GlobalFlags = []cli.Flag{
},
cli.IntFlag{
Name: "workers, w",
Usage: "maximum `NUMBER` of indexing workers",
Usage: "maximum `NUMBER` of indexing workers, default depends on the number of physical cores",
EnvVar: "PHOTOPRISM_WORKERS",
Value: cpuid.CPU.PhysicalCores / 2,
},
@ -148,11 +153,6 @@ var GlobalFlags = []cli.Flag{
Usage: "disable built-in WebDAV server",
EnvVar: "PHOTOPRISM_DISABLE_WEBDAV",
},
cli.BoolFlag{
Name: "disable-backups",
Usage: "disable creating YAML metadata backup sidecar files",
EnvVar: "PHOTOPRISM_DISABLE_BACKUPS",
},
cli.BoolFlag{
Name: "disable-settings",
Usage: "disable settings UI and API",
@ -163,9 +163,14 @@ var GlobalFlags = []cli.Flag{
Usage: "disable reverse geocoding and maps",
EnvVar: "PHOTOPRISM_DISABLE_PLACES",
},
cli.BoolFlag{
Name: "disable-backups",
Usage: "disable creating YAML metadata backup files",
EnvVar: "PHOTOPRISM_DISABLE_BACKUPS",
},
cli.BoolFlag{
Name: "disable-exiftool",
Usage: "disable metadata extraction with ExifTool",
Usage: "disable creating JSON metadata sidecar files with ExifTool",
EnvVar: "PHOTOPRISM_DISABLE_EXIFTOOL",
},
cli.BoolFlag{
@ -175,22 +180,22 @@ var GlobalFlags = []cli.Flag{
},
cli.BoolFlag{
Name: "disable-darktable",
Usage: "disable RAW file conversion with Darktable",
Usage: "disable converting RAW files with Darktable",
EnvVar: "PHOTOPRISM_DISABLE_DARKTABLE",
},
cli.BoolFlag{
Name: "disable-rawtherapee",
Usage: "disable RAW file conversion with RawTherapee",
Usage: "disable converting RAW files with RawTherapee",
EnvVar: "PHOTOPRISM_DISABLE_RAWTHERAPEE",
},
cli.BoolFlag{
Name: "disable-sips",
Usage: "disable RAW file conversion with Sips on macOS",
Usage: "disable converting RAW files with Sips (macOS only)",
EnvVar: "PHOTOPRISM_DISABLE_SIPS",
},
cli.BoolFlag{
Name: "disable-heifconvert",
Usage: "disable HEIC/HEIF file conversion",
Usage: "disable converting HEIC/HEIF files",
EnvVar: "PHOTOPRISM_DISABLE_HEIFCONVERT",
},
cli.BoolFlag{
@ -351,7 +356,7 @@ var GlobalFlags = []cli.Flag{
},
cli.StringFlag{
Name: "sips-bin",
Usage: "Sips `COMMAND` for RAW file conversion on macOS",
Usage: "Sips `COMMAND` for RAW file conversion (macOS only)",
Value: "sips",
EnvVar: "PHOTOPRISM_SIPS_BIN",
},
@ -393,12 +398,12 @@ var GlobalFlags = []cli.Flag{
},
cli.StringFlag{
Name: "download-token",
Usage: "custom download URL `TOKEN` (default: randomly generated)",
Usage: "custom download URL `TOKEN` (default: random)",
EnvVar: "PHOTOPRISM_DOWNLOAD_TOKEN",
},
cli.StringFlag{
Name: "preview-token",
Usage: "custom thumbnail and streaming URL `TOKEN` (default: randomly generated)",
Usage: "custom thumbnail and streaming URL `TOKEN` (default: random)",
EnvVar: "PHOTOPRISM_PREVIEW_TOKEN",
},
cli.StringFlag{
@ -484,9 +489,4 @@ var GlobalFlags = []cli.Flag{
Value: face.MatchDist,
EnvVar: "PHOTOPRISM_FACE_MATCH_DIST",
},
cli.StringFlag{
Name: "pid-filename",
Usage: "process id `FILENAME` when running in daemon mode",
EnvVar: "PHOTOPRISM_PID_FILENAME",
},
}

View file

@ -221,12 +221,12 @@ func (c *Config) ExifToolBin() string {
return findExecutable(c.options.ExifToolBin, "exiftool")
}
// Automatically create JSON sidecar files using Exiftool.
// ExifToolJson tests if creating JSON metadata sidecar files with Exiftool is enabled.
func (c *Config) ExifToolJson() bool {
return !c.DisableExifTool()
}
// Automatically backup metadata to YAML sidecar files.
// BackupYaml tests if creating YAML backups is enabled.
func (c *Config) BackupYaml() bool {
return !c.DisableBackups()
}