-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
38 lines (34 loc) · 874 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
package main
import (
"fmt"
"log"
"os"
"slices"
"github.com/aeazer/dirserver/cmd"
"github.com/aeazer/dirserver/utils/color"
)
const (
modeShare = "share"
modeUpload = "upload"
helpMark = "-h"
)
func main() {
if len(os.Args) == 1 || !slices.Contains([]string{modeShare, modeUpload, helpMark}, os.Args[1]) {
fmt.Printf("unknown command mod, you can use dirserver -h to show usage.\n")
os.Exit(1)
}
cmdMap := cmd.Register()
if os.Args[1] == helpMark {
fmt.Printf("\nGitHub: %s\n\n", color.BlueDA.Dyeing("https://github.com/aeazer/dirserver"))
fmt.Printf("%s:\n %s [command] [-subcommand]\n",
color.BlueDA.Dyeing("Usage"), color.GreenDA.Dyeing("dirserver"))
for _, commander := range cmdMap {
_ = commander.Run()
}
os.Exit(0)
}
err := cmdMap[os.Args[1]].Run()
if err != nil {
log.Fatalf("command run occured error: %v\n", err)
}
}