-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
57 lines (46 loc) · 1.19 KB
/
main.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"bufio"
"fmt"
cleanold "organizer/cleanOld"
"organizer/logger"
"organizer/organizer"
"organizer/styles"
"os"
"strings"
"github.com/charmbracelet/log"
)
func main() {
in := bufio.NewReader(os.Stdin)
Stdlog := logger.Out()
logFile := logger.SetupLogger()
defer logger.CloseLogger(logFile)
fmt.Println(styles.WelcomeStyle.Render("Welcome to Organizer !!"))
fmt.Println(styles.QuestionStyle.Render("What do you want to perform ? (cleanOld / organize)"))
fmt.Print(styles.ArrStyle.Render("> "))
userResp, err := in.ReadString('\n')
checkerr(err, Stdlog)
userResp = strings.TrimSuffix(userResp, "\n")
userResp = strings.TrimSuffix(userResp, "\r")
if userResp == "organize" {
organizer.Organizer()
} else if userResp == "cleanOld" {
cleanold.CleanOld()
} else {
customError(styles.InfoStyle.Render("Command not found"), Stdlog)
}
fmt.Println(styles.InputPromptStyle.Render("Press Enter key to close"))
_, err = in.ReadString('\n')
checkerr(err, Stdlog)
}
func checkerr(err error, Stdlog *log.Logger) {
if err != nil {
Stdlog.Error(err)
log.Fatal(err)
return
}
}
func customError(err string, Stdlog *log.Logger) {
Stdlog.Error(err)
log.Fatal(err)
}