7e7ba69982
This also adds the ability to change the client role if needed and improves the usage information and output of the CLI commands. Signed-off-by: Michael Mayer <michael@photoprism.app>
55 lines
1.2 KiB
Go
55 lines
1.2 KiB
Go
package commands
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/urfave/cli"
|
|
|
|
"github.com/photoprism/photoprism/internal/config"
|
|
"github.com/photoprism/photoprism/internal/entity"
|
|
"github.com/photoprism/photoprism/pkg/clean"
|
|
"github.com/photoprism/photoprism/pkg/report"
|
|
)
|
|
|
|
// ClientsShowCommand configures the command name, flags, and action.
|
|
var ClientsShowCommand = cli.Command{
|
|
Name: "show",
|
|
Usage: "Shows client configuration details",
|
|
ArgsUsage: "[id]",
|
|
Flags: report.CliFlags,
|
|
Action: clientsShowAction,
|
|
}
|
|
|
|
// clientsShowAction displays the current client application settings
|
|
func clientsShowAction(ctx *cli.Context) error {
|
|
return CallWithDependencies(ctx, func(conf *config.Config) error {
|
|
id := clean.UID(ctx.Args().First())
|
|
|
|
// Name or UID provided?
|
|
if id == "" {
|
|
return cli.ShowSubcommandHelp(ctx)
|
|
}
|
|
|
|
// Find client record.
|
|
var m *entity.Client
|
|
|
|
m = entity.FindClientByUID(id)
|
|
|
|
if m == nil {
|
|
return fmt.Errorf("client %s not found", clean.LogQuote(id))
|
|
}
|
|
|
|
// Get client information.
|
|
rows, cols := m.Report(true)
|
|
|
|
// Sort values by name.
|
|
report.Sort(rows)
|
|
|
|
// Show client information.
|
|
result, err := report.RenderFormat(rows, cols, report.CliFormat(ctx))
|
|
|
|
fmt.Printf("\n%s\n", result)
|
|
|
|
return err
|
|
})
|
|
}
|