init present action
Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
37
leak-utils/parquet/present.go
Normal file
37
leak-utils/parquet/present.go
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
package parquet
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/anotherhadi/eleakxir/leak-utils/settings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type dataleak struct {
|
||||||
|
Path string
|
||||||
|
Name string
|
||||||
|
Columns []string
|
||||||
|
Length uint64
|
||||||
|
Size uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
func Present(cacheFile string) error {
|
||||||
|
dataleaks := []dataleak{}
|
||||||
|
|
||||||
|
data, err := os.ReadFile(cacheFile)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("error reading cache file: %w", err)
|
||||||
|
}
|
||||||
|
if err := json.Unmarshal(data, &dataleaks); err != nil {
|
||||||
|
return fmt.Errorf("error reading cache file: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, d := range dataleaks {
|
||||||
|
fmt.Println(settings.Header.Render(d.Name))
|
||||||
|
fmt.Println(settings.Base.Render("Length: ", fmt.Sprintf("%d", d.Length), " rows"))
|
||||||
|
fmt.Println()
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user