-
Notifications
You must be signed in to change notification settings - Fork 1
/
cmd_info.go
40 lines (31 loc) · 829 Bytes
/
cmd_info.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"fmt"
"os"
"github.com/parquet-go/parquet-go"
"github.com/stoewer/parquet-cli/pkg/inspect"
"github.com/stoewer/parquet-cli/pkg/output"
)
type info struct {
outputOptions
File string `arg:""`
}
func (i *info) Run() error {
file, err := os.Open(i.File)
if err != nil {
return fmt.Errorf("unable to open file '%s': %w", i.File, err)
}
stat, err := file.Stat()
if err != nil {
return fmt.Errorf("unable to get stat for '%s': %w", i.File, err)
}
pfile, err := parquet.OpenFile(file, stat.Size())
if err != nil {
return fmt.Errorf("unable to read file '%s': %w", i.File, err)
}
fileInfo, err := inspect.NewFileInfo(file, pfile)
if err != nil {
return fmt.Errorf("unable to read file info for '%s': %w", i.File, err)
}
return output.PrintTable(os.Stdout, i.Output, fileInfo)
}