-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
61 lines (54 loc) · 1.06 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
58
59
60
61
package main
import (
"fmt"
"os"
)
func main() {
parseFlags()
if hFlag {
welcome()
return
}
if gFlag {
printCurrentPath()
return
}
if sFlag {
printStatus()
return
}
if pFlag {
printCleanPath()
return
}
welcome()
}
func welcome() {
fmt.Println(`
Welcome to cleanpath, a lightweight Go CLI application to show your duplicates in your PATH variable!
Usage: cleanpath [OPTIONS]
Options:
-h, Shows help page.
-g, Shows your current PATH.
-s, Prints status about the number of duplicates and the duplicates itself.
-p, Prints what would your clean path look like.
`)
}
func printCurrentPath() {
fmt.Printf("Your current path is:\n%s\n", os.Getenv("PATH"))
}
func printStatus() {
splitUniqAndDuplicates()
if getDuplicateNumber() < 1 {
fmt.Println("You don't have any duplicates!")
} else {
fmt.Printf("You have %d number of duplicates in your path, which are the followings:\n\n", getDuplicateNumber())
for _, v := range duplicates {
fmt.Println(v)
}
}
}
func printCleanPath() {
newPath := createNewPath()
fmt.Println(newPath)
}