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
|
|
|
)
|
|
|
|
|
2023-01-25 11:41:39 +01:00
|
|
|
// ShowFileFormatsCommand configures the command name, flags, and action.
|
|
|
|
var ShowFileFormatsCommand = cli.Command{
|
|
|
|
Name: "file-formats",
|
|
|
|
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
|
|
|
}),
|
2023-01-25 11:41:39 +01:00
|
|
|
Action: showFileFormatsAction,
|
2022-04-12 13:28:28 +02:00
|
|
|
}
|
|
|
|
|
2023-01-25 11:41:39 +01:00
|
|
|
// showFileFormatsAction lists supported media and sidecar file formats.
|
|
|
|
func showFileFormatsAction(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
|
|
|
}
|