2022-04-12 11:28:28 +00:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/urfave/cli"
|
2022-04-12 17:14:21 +00:00
|
|
|
|
|
|
|
"github.com/photoprism/photoprism/pkg/fs"
|
2022-04-15 07:42:07 +00:00
|
|
|
"github.com/photoprism/photoprism/pkg/media"
|
2022-04-12 17:14:21 +00:00
|
|
|
"github.com/photoprism/photoprism/pkg/report"
|
2022-04-12 11:28:28 +00:00
|
|
|
)
|
|
|
|
|
2022-04-14 10:30:47 +00:00
|
|
|
// ShowFormatsCommand configures the command name, flags, and action.
|
2022-04-12 11:28:28 +00:00
|
|
|
var ShowFormatsCommand = cli.Command{
|
2022-04-12 17:14:21 +00:00
|
|
|
Name: "formats",
|
2022-04-13 07:48:51 +00:00
|
|
|
Usage: "Lists supported media and sidecar file formats",
|
2022-04-12 17:14:21 +00:00
|
|
|
Flags: []cli.Flag{
|
|
|
|
cli.BoolFlag{
|
2022-04-15 07:42:07 +00:00
|
|
|
Name: "short, s",
|
|
|
|
Usage: "hides format descriptions",
|
2022-04-12 17:14:21 +00:00
|
|
|
},
|
|
|
|
cli.BoolFlag{
|
2022-04-14 08:49:56 +00:00
|
|
|
Name: "md, m",
|
|
|
|
Usage: "renders valid Markdown",
|
2022-04-12 17:14:21 +00:00
|
|
|
},
|
|
|
|
},
|
2022-04-12 11:28:28 +00:00
|
|
|
Action: showFormatsAction,
|
|
|
|
}
|
|
|
|
|
|
|
|
// showFormatsAction lists supported media and sidecar file formats.
|
|
|
|
func showFormatsAction(ctx *cli.Context) error {
|
2022-04-15 07:42:07 +00:00
|
|
|
rows, cols := media.Report(fs.Extensions.Types(true), !ctx.Bool("short"), true, true)
|
2022-04-14 08:49:56 +00:00
|
|
|
fmt.Println(report.Table(rows, cols, ctx.Bool("md")))
|
2022-04-12 17:14:21 +00:00
|
|
|
|
2022-04-12 11:28:28 +00:00
|
|
|
return nil
|
|
|
|
}
|