github.com/fraugster/parquet-go@v0.12.0/cmd/parquet-tool/cmds/head.go (about) 1 package cmds 2 3 import ( 4 "log" 5 "os" 6 7 "github.com/spf13/cobra" 8 ) 9 10 var recordCount *int 11 12 func init() { 13 recordCount = headCmd.PersistentFlags().IntP("records", "n", 5, "The number of records to show") 14 rootCmd.AddCommand(headCmd) 15 } 16 17 var headCmd = &cobra.Command{ 18 Use: "head file-name.parquet", 19 Short: "Prints the first n record of the Parquet file", 20 Run: func(cmd *cobra.Command, args []string) { 21 if len(args) != 1 { 22 _ = cmd.Usage() 23 os.Exit(1) 24 } 25 26 if err := catFile(os.Stdout, args[0], *recordCount); err != nil { 27 log.Fatal(err) 28 } 29 }, 30 }