-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
45 lines (38 loc) · 837 Bytes
/
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
package main
import (
"fmt"
"os"
"path/filepath"
"github.com/rafi993/al/file"
)
func main() {
argsWithoutProg := os.Args[1:]
home, err := os.UserHomeDir()
fileName := filepath.Join(home, "al.txt")
if err == nil {
if len(argsWithoutProg) >= 1 {
command := argsWithoutProg[0]
switch command {
case "list":
file.ListAlias(fileName)
case "add":
file.AddAlias(fileName, argsWithoutProg)
case "rm":
file.RemoveAlias(fileName, argsWithoutProg[1])
case "reset":
file.ResetAlias(fileName)
default:
file.CallAlias(fileName, argsWithoutProg[0])
}
} else {
fmt.Println(`
al ls - List all alias\n
al add alias cmd - Add new alias\n
al rm alias - Remove alias
al reset - remove all alias and start fresh
`)
}
} else {
fmt.Println("Unable to get your home directory")
}
}