-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcli.go
More file actions
47 lines (40 loc) · 1.14 KB
/
cli.go
File metadata and controls
47 lines (40 loc) · 1.14 KB
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
41
42
43
44
45
46
47
// This file is part of go-pst (https://www.go-pst.org/)
// Copyright (C) 2020 Marten Mooij (https://www.mooijtech.com/)
package main
import (
"flag"
"github.com/mooijtech/go-pst/pst"
log "github.com/sirupsen/logrus"
"os"
)
func main() {
inputFile := flag.String("parse", "", "File path to parse")
logLevel := flag.String("log", "debug", "Set the logging level (info, warn, fatal, error, debug or trace)")
flag.Parse()
// Input validation
if *inputFile == "" {
log.Fatal("Please specify a file path with the \"-parse\" flag.")
} else if _, err := os.Stat(*inputFile); os.IsNotExist(err) {
log.Fatal("The specified file path does not exist.")
}
// Set logging level
switch *logLevel {
case "info":
log.SetLevel(log.InfoLevel)
case "warn":
log.SetLevel(log.WarnLevel)
case "fatal":
log.SetLevel(log.FatalLevel)
case "error":
log.SetLevel(log.ErrorLevel)
case "debug":
log.SetLevel(log.DebugLevel)
case "trace":
log.SetLevel(log.TraceLevel)
default:
log.SetLevel(log.DebugLevel)
}
log.Infof("Starting go-pst v%s...", pst.Version)
log.Infof("Using logging level: %s...", log.GetLevel().String())
pst.ParseFile(*inputFile)
}