github.com/q2/git-lfs@v0.5.1-0.20150410234700-03a0d4cec40e/commands/command_ls_files.go (about) 1 package commands 2 3 import ( 4 "github.com/github/git-lfs/git" 5 "github.com/github/git-lfs/scanner" 6 "github.com/spf13/cobra" 7 ) 8 9 var ( 10 lsFilesCmd = &cobra.Command{ 11 Use: "ls-files", 12 Short: "Show information about Git LFS files", 13 Run: lsFilesCommand, 14 } 15 ) 16 17 func lsFilesCommand(cmd *cobra.Command, args []string) { 18 var ref string 19 var err error 20 21 if len(args) == 1 { 22 ref = args[0] 23 } else { 24 ref, err = git.CurrentRef() 25 if err != nil { 26 Panic(err, "Could not ls-files") 27 } 28 } 29 30 pointers, err := scanner.Scan(ref, "") 31 if err != nil { 32 Panic(err, "Could not scan for Git LFS files") 33 } 34 35 for _, p := range pointers { 36 Print(p.Name) 37 } 38 } 39 40 func init() { 41 RootCmd.AddCommand(lsFilesCmd) 42 }