git-lfs/commands/command_ls_files.go
2015-01-30 14:42:46 -05:00

43 lines
705 B
Go

package commands
import (
"github.com/hawser/git-hawser/git"
"github.com/hawser/git-hawser/scanner"
"github.com/spf13/cobra"
)
var (
lsFilesCmd = &cobra.Command{
Use: "ls-files",
Short: "Show information about hawser files",
Run: lsFilesCommand,
}
)
func lsFilesCommand(cmd *cobra.Command, args []string) {
var ref string
var err error
if len(args) == 1 {
ref = args[0]
} else {
ref, err = git.CurrentRef()
if err != nil {
Panic(err, "Could not ls-files")
}
}
pointers, err := scanner.Scan(ref, "")
if err != nil {
Panic(err, "Could not scan for hawser files")
}
for _, p := range pointers {
Print(p.Name)
}
}
func init() {
RootCmd.AddCommand(lsFilesCmd)
}