-
Notifications
You must be signed in to change notification settings - Fork 1
/
command.go
56 lines (50 loc) · 1.67 KB
/
command.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
package main
import (
"fmt"
"github.com/spf13/cobra"
)
var myPfsCmd = &cobra.Command{
Use: "mypfs",
Short: "My personal file server",
Long: `A personal file server for sharing files with and receiving files
from people on your network.
Complete documentation is available at http://github.com/joncrlsn/mypfs`,
Run: func(cmd *cobra.Command, args []string) {
action = "up/down"
},
}
var uploadCmd = &cobra.Command{
Use: "upload",
Short: "Allow file uploads to the current directory",
Long: `Starts web server that only allows uploading of files to
the current directory. No downloading is allowed`,
Run: func(cmd *cobra.Command, args []string) {
action = "up"
},
}
var downloadCmd = &cobra.Command{
Use: "download",
Short: "Allow file downloads from the current directory",
Long: `Starts web server that only allows downloading of files from
the current directory. No uploading is allowed`,
Run: func(cmd *cobra.Command, args []string) {
action = "down"
},
}
var versionCmd = &cobra.Command{
Use: "version",
Short: "Prints the version number",
Long: `Displays the version number for mypfs`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("mypfs (My Personal File Server) version", version)
action = "version"
},
}
func init() {
myPfsCmd.AddCommand(uploadCmd)
myPfsCmd.AddCommand(downloadCmd)
myPfsCmd.AddCommand(versionCmd)
myPfsCmd.PersistentFlags().IntVarP(&port, "port", "p", 8080, "port number to listen on")
myPfsCmd.PersistentFlags().Int64VarP(&timeoutMinutes, "timeout", "t", 10, "number of minutes to leave this running")
myPfsCmd.PersistentFlags().BoolVarP(&insecure, "insecure", "k", false, "true = do not require secret username")
}