MCPcopy Create free account
hub / github.com/plexdrive/plexdrive / main

Function main

main.go:32–235  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30var Version = "%VERSION%"
31
32func main() {
33 // Find users home directory
34 usr, err := user.Current()
35 home := ""
36 if err != nil {
37 // Fall back to reading $HOME - work around user.Current() not
38 // working for cross compiled binaries on OSX or freebsd.
39 // https://github.com/golang/go/issues/6376
40 home = os.Getenv("HOME")
41 if home == "" {
42 panic(fmt.Sprintf("Could not read users homedir and HOME is not set: %v\n", err))
43 }
44 } else {
45 home = usr.HomeDir
46 }
47
48 // parse the command line arguments
49 argLogLevel := flag.IntP("verbosity", "v", 0, "Set the log level (0 = error, 1 = warn, 2 = info, 3 = debug, 4 = trace)")
50 argRootNodeID := flag.String("root-node-id", "root", "The ID of the root node to mount (use this for only mount a sub directory)")
51 argDriveID := flag.String("drive-id", "", "The ID of the shared drive to mount (including team drives)")
52 argConfigPath := flag.StringP("config", "c", filepath.Join(home, ".plexdrive"), "The path to the configuration directory")
53 argCacheFile := flag.String("cache-file", "", "Path of the cache file (default \"cache.bolt\" in configuration directory)")
54 argChunkFile := flag.String("chunk-file", "", "Path of the chunk cache file (default \"chunks.dat\" in configuration directory)")
55 argChunkDiskCache := flag.Bool("chunk-disk-cache", false, "Enable disk based chunk cache to --chunk-file")
56 argChunkSize := flag.String("chunk-size", "10M", "The size of each chunk that is downloaded (units: B, K, M, G)")
57 argChunkLoadThreads := flag.Int("chunk-load-threads", max(runtime.NumCPU()/2, 1), "The number of threads to use for downloading chunks")
58 argChunkCheckThreads := flag.Int("chunk-check-threads", max(runtime.NumCPU()/2, 1), "The number of threads to use for checking chunk existence")
59 argChunkLoadAhead := flag.Int("chunk-load-ahead", max(runtime.NumCPU()-1, 1), "The number of chunks that should be read ahead")
60 argMaxChunks := flag.Int("max-chunks", runtime.NumCPU()*2, "The maximum number of chunks to be stored in memory")
61 argRefreshInterval := flag.Duration("refresh-interval", 1*time.Minute, "The time to wait till checking for changes")
62 argMountOptions := flag.StringP("fuse-options", "o", "", "Fuse mount options (e.g. --fuse-options allow_other,direct_io,...)")
63 argVersion := flag.Bool("version", false, "Displays program's version information")
64 argUID := flag.Int64("uid", -1, "Set the mounts UID (-1 = default permissions)")
65 argGID := flag.Int64("gid", -1, "Set the mounts GID (-1 = default permissions)")
66 argUmask := flag.Uint32("umask", 0, "Override the default file permissions")
67 argAcknowledgeAbuse := flag.Bool("acknowledge-abuse", false, "Allows files identified as abusive (malware, etc.) to be downloaded in Drive")
68 // argDownloadSpeedLimit := flag.String("speed-limit", "", "This value limits the download speed, e.g. 5M = 5MB/s per chunk (units: B, K, M, G)")
69 flag.Parse()
70
71 // display version information
72 if *argVersion {
73 fmt.Println(Version)
74 return
75 }
76
77 argCommand := flag.Arg(0)
78
79 if argCommand == "mount" {
80 // check if mountpoint is specified
81 argMountPoint := flag.Arg(1)
82 if "" == argMountPoint {
83 flag.Usage()
84 fmt.Println()
85 panic(fmt.Errorf("Mountpoint not specified"))
86 }
87
88 // set default paths, must happen after parsing to get custom config path
89 if !flag.Lookup("cache-file").Changed {

Callers

nothing calls this directly

Calls 12

CloseMethod · 0.95
ReadFunction · 0.92
CreateFunction · 0.92
NewCacheFunction · 0.92
NewClientFunction · 0.92
NewManagerFunction · 0.92
MountFunction · 0.92
maxFunction · 0.85
parseSizeArgFunction · 0.85
checkOsSignalsFunction · 0.85
StringMethod · 0.80
LookupMethod · 0.80

Tested by

no test coverage detected