2018-09-24 09:53:16 +02:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2018-10-31 07:14:33 +01:00
|
|
|
|
2022-04-12 19:14:21 +02:00
|
|
|
"github.com/sirupsen/logrus"
|
2018-09-24 09:53:16 +02:00
|
|
|
"github.com/urfave/cli"
|
2021-09-22 19:33:41 +02:00
|
|
|
|
|
|
|
"github.com/photoprism/photoprism/internal/config"
|
2022-04-12 19:14:21 +02:00
|
|
|
"github.com/photoprism/photoprism/pkg/report"
|
2018-09-24 09:53:16 +02:00
|
|
|
)
|
|
|
|
|
2022-04-14 12:30:47 +02:00
|
|
|
// ShowConfigCommand configures the command name, flags, and action.
|
2022-04-12 13:28:28 +02:00
|
|
|
var ShowConfigCommand = cli.Command{
|
2022-04-17 12:30:33 +02:00
|
|
|
Name: "config",
|
2022-05-10 20:47:45 +02:00
|
|
|
Usage: "Displays global config options and their current values",
|
2022-04-17 12:30:33 +02:00
|
|
|
Flags: report.CliFlags,
|
2022-04-12 13:28:28 +02:00
|
|
|
Action: showConfigAction,
|
2018-09-24 09:53:16 +02:00
|
|
|
}
|
|
|
|
|
2022-04-14 12:30:47 +02:00
|
|
|
// showConfigAction shows global config option names and values.
|
2022-04-12 13:28:28 +02:00
|
|
|
func showConfigAction(ctx *cli.Context) error {
|
2019-05-06 23:18:10 +02:00
|
|
|
conf := config.NewConfig(ctx)
|
2022-04-12 19:14:21 +02:00
|
|
|
conf.SetLogLevel(logrus.FatalLevel)
|
2018-09-24 09:53:16 +02:00
|
|
|
|
2022-04-14 10:49:56 +02:00
|
|
|
rows, cols := conf.Report()
|
2020-05-30 14:52:47 +02:00
|
|
|
|
2022-04-17 12:30:33 +02:00
|
|
|
result, err := report.Render(rows, cols, report.CliFormat(ctx))
|
2021-10-05 22:33:29 +02:00
|
|
|
|
2022-04-17 12:30:33 +02:00
|
|
|
fmt.Println(result)
|
|
|
|
|
|
|
|
return err
|
2018-09-24 09:53:16 +02:00
|
|
|
}
|