-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
66 lines (57 loc) · 1.42 KB
/
main.go
File metadata and controls
66 lines (57 loc) · 1.42 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
import (
"fmt"
"os"
"github.com/spf13/cobra"
"github.com/mmahmoudian/tmp-place/cmd/admin"
"github.com/mmahmoudian/tmp-place/cmd/janitor"
"github.com/mmahmoudian/tmp-place/cmd/server"
"github.com/mmahmoudian/tmp-place/cmd/setup"
)
func main() {
//root of the CLI application
var rootCmd = &cobra.Command{
Use: "tmp-place",
Short: "tmp-place is a tool for admin tasks",
}
// server subcommand
var ServerCmd = &cobra.Command{
Use: "server",
Short: "Start a webserver that prints incoming requests",
Run: func(cmd *cobra.Command, args []string) {
server.ServerHandler(cmd, args)
},
}
rootCmd.AddCommand(ServerCmd)
// setup subcommand
var SetupCmd = &cobra.Command{
Use: "setup",
Short: "Set up the server",
Run: func(cmd *cobra.Command, args []string) {
setup.SetupHandler(cmd, args)
},
}
rootCmd.AddCommand(SetupCmd)
// admin subcommand
var AdminCmd = &cobra.Command{
Use: "admin",
Short: "Perform admin tasks",
Run: func(cmd *cobra.Command, args []string) {
admin.AdminHandler(cmd, args)
},
}
rootCmd.AddCommand(AdminCmd)
// janitor subcommand
var janitorCmd = &cobra.Command{
Use: "janitor",
Short: "Perform cleanup tasks for the uploaded files",
Run: func(cmd *cobra.Command, args []string) {
janitor.JanitorHandler(cmd, args)
},
}
rootCmd.AddCommand(janitorCmd)
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}