git-lfs/commands/command_ext.go

65 lines
1.1 KiB
Go
Raw Normal View History

2015-07-10 20:54:06 +00:00
package commands
import (
"fmt"
"github.com/github/git-lfs/config"
2015-07-10 20:54:06 +00:00
"github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra"
)
var (
extCmd = &cobra.Command{
2015-09-17 22:08:28 +00:00
Use: "ext",
Run: extCommand,
2015-07-10 20:54:06 +00:00
}
extListCmd = &cobra.Command{
Use: "list",
Short: "View details for specified extensions",
Run: extListCommand,
}
)
func extCommand(cmd *cobra.Command, args []string) {
printAllExts()
}
func extListCommand(cmd *cobra.Command, args []string) {
n := len(args)
if n == 0 {
printAllExts()
2015-07-24 04:53:36 +00:00
return
}
cfg := config.Config
2015-07-24 04:53:36 +00:00
for _, key := range args {
ext := cfg.Extensions()[key]
2015-07-24 04:53:36 +00:00
printExt(ext)
2015-07-10 20:54:06 +00:00
}
}
func printAllExts() {
cfg := config.Config
2015-07-10 20:54:06 +00:00
extensions, err := cfg.SortedExtensions()
2015-07-10 20:54:06 +00:00
if err != nil {
fmt.Println(err)
return
}
for _, ext := range extensions {
printExt(ext)
}
}
2016-05-13 16:43:04 +00:00
func printExt(ext config.Extension) {
2015-07-10 20:54:06 +00:00
Print("Extension: %s", ext.Name)
Print(" clean = %s", ext.Clean)
Print(" smudge = %s", ext.Smudge)
Print(" priority = %d", ext.Priority)
}
func init() {
extCmd.AddCommand(extListCmd)
RootCmd.AddCommand(extCmd)
}