Config: Update CLI "photoprism show" sub-command names

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer 2023-01-25 11:41:39 +01:00
parent 8e73e5cebe
commit 2cab5f7534
7 changed files with 44 additions and 48 deletions

View file

@ -10,10 +10,10 @@ var ShowCommand = cli.Command{
Usage: "Shows supported formats, features, and config options", Usage: "Shows supported formats, features, and config options",
Subcommands: []cli.Command{ Subcommands: []cli.Command{
ShowConfigCommand, ShowConfigCommand,
ShowFlagsCommand, ShowConfigOptionsCommand,
ShowOptionsCommand, ShowConfigYamlCommand,
ShowFiltersCommand, ShowSearchFiltersCommand,
ShowFormatsCommand, ShowFileFormatsCommand,
ShowTagsCommand, ShowMetadataCommand,
}, },
} }

View file

@ -10,13 +10,12 @@ import (
"github.com/photoprism/photoprism/pkg/report" "github.com/photoprism/photoprism/pkg/report"
) )
// ShowFlagsCommand configures the command name, flags, and action. // ShowConfigOptionsCommand configures the command name, flags, and action.
var ShowFlagsCommand = cli.Command{ var ShowConfigOptionsCommand = cli.Command{
Name: "flags", Name: "config-options",
Aliases: []string{"env", "vars"},
Usage: "Displays supported environment variables and CLI flags", Usage: "Displays supported environment variables and CLI flags",
Flags: report.CliFlags, Flags: report.CliFlags,
Action: showFlagsAction, Action: showConfigOptionsAction,
} }
var faceFlagsInfo = `!!! info "" var faceFlagsInfo = `!!! info ""
@ -24,8 +23,8 @@ var faceFlagsInfo = `!!! info ""
We recommend that only advanced users change these parameters:` We recommend that only advanced users change these parameters:`
// showFlagsAction displays supported environment variables and CLI flags. // showConfigOptionsAction displays supported environment variables and CLI flags.
func showFlagsAction(ctx *cli.Context) error { func showConfigOptionsAction(ctx *cli.Context) error {
conf := config.NewConfig(ctx) conf := config.NewConfig(ctx)
conf.SetLogLevel(logrus.FatalLevel) conf.SetLogLevel(logrus.FatalLevel)

View file

@ -10,16 +10,16 @@ import (
"github.com/photoprism/photoprism/pkg/report" "github.com/photoprism/photoprism/pkg/report"
) )
// ShowOptionsCommand configures the command name, flags, and action. // ShowConfigYamlCommand configures the command name, flags, and action.
var ShowOptionsCommand = cli.Command{ var ShowConfigYamlCommand = cli.Command{
Name: "options", Name: "config-yaml",
Usage: "Displays supported YAML config options and CLI flags", Usage: "Displays supported YAML config options and CLI flags",
Flags: report.CliFlags, Flags: report.CliFlags,
Action: showOptionsAction, Action: showConfigYamlAction,
} }
// showOptionsAction displays supported YAML config options and CLI flag. // showConfigYamlAction displays supported YAML config options and CLI flag.
func showOptionsAction(ctx *cli.Context) error { func showConfigYamlAction(ctx *cli.Context) error {
conf := config.NewConfig(ctx) conf := config.NewConfig(ctx)
conf.SetLogLevel(logrus.TraceLevel) conf.SetLogLevel(logrus.TraceLevel)

View file

@ -10,20 +10,19 @@ import (
"github.com/photoprism/photoprism/pkg/report" "github.com/photoprism/photoprism/pkg/report"
) )
// ShowFormatsCommand configures the command name, flags, and action. // ShowFileFormatsCommand configures the command name, flags, and action.
var ShowFormatsCommand = cli.Command{ var ShowFileFormatsCommand = cli.Command{
Name: "formats", Name: "file-formats",
Aliases: []string{"filetypes"},
Usage: "Displays supported media and sidecar file formats", Usage: "Displays supported media and sidecar file formats",
Flags: append(report.CliFlags, cli.BoolFlag{ Flags: append(report.CliFlags, cli.BoolFlag{
Name: "short, s", Name: "short, s",
Usage: "hide format descriptions", Usage: "hide format descriptions",
}), }),
Action: showFormatsAction, Action: showFileFormatsAction,
} }
// showFormatsAction lists supported media and sidecar file formats. // showFileFormatsAction lists supported media and sidecar file formats.
func showFormatsAction(ctx *cli.Context) error { func showFileFormatsAction(ctx *cli.Context) error {
rows, cols := media.Report(fs.Extensions.Types(true), !ctx.Bool("short"), true, true) rows, cols := media.Report(fs.Extensions.Types(true), !ctx.Bool("short"), true, true)
result, err := report.RenderFormat(rows, cols, report.CliFormat(ctx)) result, err := report.RenderFormat(rows, cols, report.CliFormat(ctx))

View file

@ -10,20 +10,19 @@ import (
"github.com/photoprism/photoprism/pkg/report" "github.com/photoprism/photoprism/pkg/report"
) )
// ShowTagsCommand configures the command name, flags, and action. // ShowMetadataCommand configures the command name, flags, and action.
var ShowTagsCommand = cli.Command{ var ShowMetadataCommand = cli.Command{
Name: "tags", Name: "metadata",
Aliases: []string{"metadata"},
Usage: "Displays supported metadata tags and standards", Usage: "Displays supported metadata tags and standards",
Flags: append(report.CliFlags, cli.BoolFlag{ Flags: append(report.CliFlags, cli.BoolFlag{
Name: "short, s", Name: "short, s",
Usage: "hide links to documentation", Usage: "hide links to documentation",
}), }),
Action: showTagsAction, Action: showMetadataAction,
} }
// showTagsAction reports supported Exif and XMP metadata tags. // showMetadataAction reports supported Exif and XMP metadata tags.
func showTagsAction(ctx *cli.Context) error { func showMetadataAction(ctx *cli.Context) error {
rows, cols := meta.Report(&meta.Data{}) rows, cols := meta.Report(&meta.Data{})
// Sort rows by type data type and name. // Sort rows by type data type and name.

View file

@ -10,17 +10,16 @@ import (
"github.com/photoprism/photoprism/pkg/report" "github.com/photoprism/photoprism/pkg/report"
) )
// ShowFiltersCommand configures the command name, flags, and action. // ShowSearchFiltersCommand configures the command name, flags, and action.
var ShowFiltersCommand = cli.Command{ var ShowSearchFiltersCommand = cli.Command{
Name: "filters", Name: "search-filters",
Aliases: []string{"search"},
Usage: "Displays supported search filters with examples", Usage: "Displays supported search filters with examples",
Flags: report.CliFlags, Flags: report.CliFlags,
Action: showFiltersAction, Action: showSearchFiltersAction,
} }
// showFiltersAction displays a search filter overview with examples. // showSearchFiltersAction displays a search filter overview with examples.
func showFiltersAction(ctx *cli.Context) error { func showSearchFiltersAction(ctx *cli.Context) error {
rows, cols := form.Report(&form.SearchPhotos{}) rows, cols := form.Report(&form.SearchPhotos{})
sort.Slice(rows, func(i, j int) bool { sort.Slice(rows, func(i, j int) bool {

View file

@ -38,7 +38,7 @@ func TestShowTagsCommand(t *testing.T) {
ctx := config.CliTestContext() ctx := config.CliTestContext()
output := capture.Output(func() { output := capture.Output(func() {
err = ShowTagsCommand.Run(ctx) err = ShowMetadataCommand.Run(ctx)
}) })
if err != nil { if err != nil {
@ -59,7 +59,7 @@ func TestShowFiltersCommand(t *testing.T) {
ctx := config.CliTestContext() ctx := config.CliTestContext()
output := capture.Output(func() { output := capture.Output(func() {
err = ShowFiltersCommand.Run(ctx) err = ShowSearchFiltersCommand.Run(ctx)
}) })
if err != nil { if err != nil {
@ -80,7 +80,7 @@ func TestShowFormatsCommand(t *testing.T) {
ctx := config.CliTestContext() ctx := config.CliTestContext()
output := capture.Output(func() { output := capture.Output(func() {
err = ShowFormatsCommand.Run(ctx) err = ShowFileFormatsCommand.Run(ctx)
}) })
if err != nil { if err != nil {