2022-04-12 13:28:28 +02:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/urfave/cli"
|
2022-04-12 19:14:21 +02:00
|
|
|
|
|
|
|
"github.com/photoprism/photoprism/pkg/fs"
|
2022-04-15 09:42:07 +02:00
|
|
|
"github.com/photoprism/photoprism/pkg/media"
|
2022-04-12 19:14:21 +02:00
|
|
|
"github.com/photoprism/photoprism/pkg/report"
|
2022-04-12 13:28:28 +02:00
|
|
|
)
|
|
|
|
|
2022-04-14 12:30:47 +02:00
|
|
|
// ShowFormatsCommand configures the command name, flags, and action.
|
2022-04-12 13:28:28 +02:00
|
|
|
var ShowFormatsCommand = cli.Command{
|
2022-04-16 19:52:53 +02:00
|
|
|
Name: "formats",
|
|
|
|
Aliases: []string{"filetypes"},
|
2022-05-10 20:47:45 +02:00
|
|
|
Usage: "Displays supported media and sidecar file formats",
|
2022-04-17 12:30:33 +02:00
|
|
|
Flags: append(report.CliFlags, cli.BoolFlag{
|
|
|
|
Name: "short, s",
|
2022-04-17 15:33:40 +02:00
|
|
|
Usage: "hide format descriptions",
|
2022-04-17 12:30:33 +02:00
|
|
|
}),
|
2022-04-12 13:28:28 +02:00
|
|
|
Action: showFormatsAction,
|
|
|
|
}
|
|
|
|
|
|
|
|
// showFormatsAction lists supported media and sidecar file formats.
|
|
|
|
func showFormatsAction(ctx *cli.Context) error {
|
2022-04-15 09:42:07 +02:00
|
|
|
rows, cols := media.Report(fs.Extensions.Types(true), !ctx.Bool("short"), true, true)
|
2022-04-12 19:14:21 +02:00
|
|
|
|
2022-10-10 16:34:07 +02:00
|
|
|
result, err := report.RenderFormat(rows, cols, report.CliFormat(ctx))
|
2022-04-17 12:30:33 +02:00
|
|
|
|
|
|
|
fmt.Println(result)
|
|
|
|
|
|
|
|
return err
|
2022-04-12 13:28:28 +02:00
|
|
|
}
|