git-lfs/commands/command_ext.go
Chris Darroch a2d8e90d6e commands/command_ext.go: translate ext header only
In commit 1ddc2f2662b71d365ca7934c39b4ae56a60b5673 of
PR #4781 text translation support was added for the
"git lfs ext" command and a multi-line message was
concatenated.  However, the latter part of this text should
be fixed for all users, since it displays a listing of
the extension's settings values using defined terms.

We therefore separate the first line of the message and
let that be translated, as it contains the language-specific
header text.
2022-01-29 22:32:57 -08:00

51 lines
896 B
Go

package commands
import (
"fmt"
"github.com/git-lfs/git-lfs/v3/config"
"github.com/git-lfs/git-lfs/v3/tr"
"github.com/spf13/cobra"
)
func extCommand(cmd *cobra.Command, args []string) {
printAllExts()
}
func extListCommand(cmd *cobra.Command, args []string) {
n := len(args)
if n == 0 {
printAllExts()
return
}
for _, key := range args {
ext := cfg.Extensions()[key]
printExt(ext)
}
}
func printAllExts() {
extensions, err := cfg.SortedExtensions()
if err != nil {
fmt.Println(err)
return
}
for _, ext := range extensions {
printExt(ext)
}
}
func printExt(ext config.Extension) {
Print(tr.Tr.Get("Extension: %s", ext.Name))
Print(` clean = %s
smudge = %s
priority = %d`, ext.Clean, ext.Smudge, ext.Priority)
}
func init() {
RegisterCommand("ext", extCommand, func(cmd *cobra.Command) {
cmd.AddCommand(NewCommand("list", extListCommand))
})
}