github.com/stffabi/git-lfs@v2.3.5-0.20180214015214-8eeaa8d88902+incompatible/commands/command_ext.go (about)

     1  package commands
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/git-lfs/git-lfs/config"
     7  	"github.com/spf13/cobra"
     8  )
     9  
    10  func extCommand(cmd *cobra.Command, args []string) {
    11  	printAllExts()
    12  }
    13  
    14  func extListCommand(cmd *cobra.Command, args []string) {
    15  	n := len(args)
    16  	if n == 0 {
    17  		printAllExts()
    18  		return
    19  	}
    20  
    21  	for _, key := range args {
    22  		ext := cfg.Extensions()[key]
    23  		printExt(ext)
    24  	}
    25  }
    26  
    27  func printAllExts() {
    28  	extensions, err := cfg.SortedExtensions()
    29  	if err != nil {
    30  		fmt.Println(err)
    31  		return
    32  	}
    33  	for _, ext := range extensions {
    34  		printExt(ext)
    35  	}
    36  }
    37  
    38  func printExt(ext config.Extension) {
    39  	Print("Extension: %s", ext.Name)
    40  	Print("    clean = %s", ext.Clean)
    41  	Print("    smudge = %s", ext.Smudge)
    42  	Print("    priority = %d", ext.Priority)
    43  }
    44  
    45  func init() {
    46  	RegisterCommand("ext", extCommand, func(cmd *cobra.Command) {
    47  		cmd.AddCommand(NewCommand("list", extListCommand))
    48  	})
    49  }