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"},
|
|
|
|
Usage: "Lists supported media and sidecar file formats",
|
2022-04-17 12:30:33 +02:00
|
|
|
Flags: append(report.CliFlags, cli.BoolFlag{
|
|
|
|
Name: "short, s",
|
|
|
|
Usage: "hide links to documentation",
|
|
|
|
}),
|
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-04-17 12:30:33 +02:00
|
|
|
result, err := report.Render(rows, cols, report.CliFormat(ctx))
|
|
|
|
|
|
|
|
fmt.Println(result)
|
|
|
|
|
|
|
|
return err
|
2022-04-12 13:28:28 +02:00
|
|
|
}
|